[DRE-commits] [ruby-rubyvis] 01/01: Imported Upstream version 0.5.2

Balint Reczey rbalint at moszumanska.debian.org
Tue May 26 23:32:03 UTC 2015


This is an automated email from the git hooks/post-receive script.

rbalint pushed a commit to annotated tag upstream/0.5.2
in repository ruby-rubyvis.

commit cf74ea0cf1a8c353670619b0a45230fe27c6f684
Author: Cédric Boutillier <boutil at debian.org>
Date:   Tue Dec 11 23:55:26 2012 +0100

    Imported Upstream version 0.5.2
---
 .gemtest                                           |    0
 History.txt                                        |  177 +++
 Manifest.txt                                       |  296 +++++
 README.txt                                         |  155 +++
 Rakefile                                           |   38 +
 examples/1_basic/1a_bar_rbp_api.rb                 |   21 +
 examples/1_basic/1b_bar_pv_api.rb                  |   16 +
 examples/1_basic/2_bar_and_rule.rb                 |   28 +
 examples/1_basic/3_grouped_bars.rb                 |   23 +
 examples/1_basic/area_interpolation.rb             |   63 +
 examples/1_basic/dot.rb                            |   18 +
 examples/1_basic/fixtures/tipsy.gif                |  Bin 0 -> 58 bytes
 examples/1_basic/grid.rb                           |   30 +
 examples/1_basic/image.rb                          |   19 +
 examples/1_basic/line.rb                           |   41 +
 examples/1_basic/line_interpolation.rb             |   64 +
 .../censo_agropecuario_chile_data.rb               |   53 +
 .../2_medium/censo_agropecuario/census_treemap.rb  |   63 +
 .../2_medium/censo_agropecuario/create_data.rb     |   10 +
 examples/2_medium/censo_agropecuario/resultset.csv |   51 +
 examples/2_medium/horizon.rb                       |   58 +
 examples/2_medium/nested_grid.rb                   |   52 +
 examples/3_pv_conventional/area.rb                 |   67 ++
 examples/3_pv_conventional/bar_column_chart.rb     |   59 +
 examples/3_pv_conventional/grouped_charts.rb       |   70 ++
 examples/3_pv_conventional/line_and_step.rb        |   65 +
 examples/3_pv_conventional/pie_and_donut.rb        |   38 +
 examples/3_pv_conventional/scatterplot.rb          |   57 +
 examples/3_pv_conventional/stacked_charts.rb       |   50 +
 .../4_pv_custom/antibiotics/antibiotics_data.rb    |   20 +
 .../4_pv_custom/antibiotics/antibiotics_scatter.rb |  107 ++
 .../4_pv_custom/antibiotics/antibiotics_wedge.rb   |  142 +++
 examples/4_pv_custom/barley/barley.rb              |   97 ++
 examples/4_pv_custom/barley/barley_data.rb         |  122 ++
 examples/4_pv_custom/cars/cars.rb                  |   90 ++
 examples/4_pv_custom/cars/cars_data.rb             |  409 +++++++
 examples/4_pv_custom/crimea/crimea_data.rb         |   37 +
 examples/4_pv_custom/crimea/crimea_grouped_bar.rb  |   61 +
 examples/4_pv_custom/crimea/crimea_line.rb         |   50 +
 examples/5_pv_hierarchies/bubble_charts.rb         |   61 +
 examples/5_pv_hierarchies/bubble_charts_matrix.rb  |   64 +
 examples/5_pv_hierarchies/circle_packing.rb        |   54 +
 examples/5_pv_hierarchies/dendogram.rb             |   52 +
 examples/5_pv_hierarchies/icicle.rb                |   48 +
 examples/5_pv_hierarchies/indent.rb                |   71 ++
 examples/5_pv_hierarchies/node_link_tree.rb        |   52 +
 examples/5_pv_hierarchies/sunburst.rb              |   52 +
 examples/5_pv_hierarchies/treemap.rb               |   48 +
 examples/6_pv_networks/arc.rb                      |   32 +
 examples/6_pv_networks/matrix.rb                   |   34 +
 examples/6_pv_networks/miserables_data.rb          |  348 ++++++
 lib/rubyvis.rb                                     |  109 ++
 lib/rubyvis/color/color.rb                         |  426 +++++++
 lib/rubyvis/color/colors.rb                        |  136 +++
 lib/rubyvis/dom.rb                                 |  342 ++++++
 lib/rubyvis/flatten.rb                             |  126 ++
 lib/rubyvis/format.rb                              |   19 +
 lib/rubyvis/format/date.rb                         |   25 +
 lib/rubyvis/format/number.rb                       |  101 ++
 lib/rubyvis/histogram.rb                           |   44 +
 lib/rubyvis/internals.rb                           |  270 +++++
 lib/rubyvis/javascript_behaviour.rb                |   78 ++
 lib/rubyvis/layout.rb                              |   50 +
 lib/rubyvis/layout/arc.rb                          |  183 +++
 lib/rubyvis/layout/cluster.rb                      |  203 ++++
 lib/rubyvis/layout/grid.rb                         |  105 ++
 lib/rubyvis/layout/hierarchy.rb                    |  249 ++++
 lib/rubyvis/layout/horizon.rb                      |  153 +++
 lib/rubyvis/layout/indent.rb                       |   81 ++
 lib/rubyvis/layout/matrix.rb                       |  188 +++
 lib/rubyvis/layout/network.rb                      |  337 ++++++
 lib/rubyvis/layout/pack.rb                         |  332 ++++++
 lib/rubyvis/layout/partition.rb                    |  227 ++++
 lib/rubyvis/layout/stack.rb                        |  307 +++++
 lib/rubyvis/layout/tree.rb                         |  267 +++++
 lib/rubyvis/layout/treemap.rb                      |  359 ++++++
 lib/rubyvis/mark.rb                                | 1095 +++++++++++++++++
 lib/rubyvis/mark/anchor.rb                         |   83 ++
 lib/rubyvis/mark/area.rb                           |  227 ++++
 lib/rubyvis/mark/bar.rb                            |   69 ++
 lib/rubyvis/mark/dot.rb                            |  168 +++
 lib/rubyvis/mark/image.rb                          |   96 ++
 lib/rubyvis/mark/label.rb                          |  107 ++
 lib/rubyvis/mark/line.rb                           |  152 +++
 lib/rubyvis/mark/panel.rb                          |  138 +++
 lib/rubyvis/mark/rule.rb                           |   35 +
 lib/rubyvis/mark/shorcut_methods.rb                |  314 +++++
 lib/rubyvis/mark/wedge.rb                          |  145 +++
 lib/rubyvis/nest.rb                                |  203 ++++
 lib/rubyvis/property.rb                            |   12 +
 lib/rubyvis/scale.rb                               |   38 +
 lib/rubyvis/scale/linear.rb                        |    5 +
 lib/rubyvis/scale/log.rb                           |   73 ++
 lib/rubyvis/scale/ordinal.rb                       |  206 ++++
 lib/rubyvis/scale/quantitative.rb                  |  444 +++++++
 lib/rubyvis/scene/svg_area.rb                      |  211 ++++
 lib/rubyvis/scene/svg_bar.rb                       |   32 +
 lib/rubyvis/scene/svg_curve.rb                     |  340 ++++++
 lib/rubyvis/scene/svg_dot.rb                       |   68 ++
 lib/rubyvis/scene/svg_image.rb                     |   30 +
 lib/rubyvis/scene/svg_label.rb                     |   55 +
 lib/rubyvis/scene/svg_line.rb                      |  189 +++
 lib/rubyvis/scene/svg_panel.rb                     |  151 +++
 lib/rubyvis/scene/svg_rule.rb                      |   29 +
 lib/rubyvis/scene/svg_scene.rb                     |  217 ++++
 lib/rubyvis/scene/svg_wedge.rb                     |   58 +
 lib/rubyvis/sceneelement.rb                        |   54 +
 lib/rubyvis/transform.rb                           |   25 +
 lib/rubyvis/vector.rb                              |  104 ++
 metadata.yml                                       |  461 ++++++++
 spec/anchor_spec.rb                                |  155 +++
 spec/area_spec.rb                                  |  143 +++
 spec/bar_spec.rb                                   |   77 ++
 spec/color_spec.rb                                 |   91 ++
 spec/dom_spec.rb                                   |  225 ++++
 spec/dot_spec.rb                                   |   41 +
 spec/fixtures/anchor.html                          |   25 +
 spec/fixtures/anchor.svg                           |    1 +
 spec/fixtures/area-segmented.html                  |   29 +
 spec/fixtures/area_interpolation.html              |   66 ++
 spec/fixtures/area_interpolation.svg               |    1 +
 spec/fixtures/area_segmented.svg                   |    1 +
 spec/fixtures/dot-anchor.html                      |   33 +
 spec/fixtures/dot_anchor.svg                       |    1 +
 spec/fixtures/image.svg                            |    1 +
 spec/fixtures/layers.js                            |   28 +
 spec/fixtures/layout_arc.svg                       |    1 +
 spec/fixtures/layout_cluster.html                  |   39 +
 spec/fixtures/layout_cluster.svg                   |    1 +
 spec/fixtures/layout_cluster_left_group_2.html     |   39 +
 spec/fixtures/layout_cluster_left_group_2.svg      |    1 +
 spec/fixtures/layout_grid.html                     |   34 +
 spec/fixtures/layout_grid.svg                      |    1 +
 spec/fixtures/layout_horizon.svg                   |   24 +
 spec/fixtures/layout_indent.html                   |   39 +
 spec/fixtures/layout_indent.svg                    |    1 +
 spec/fixtures/layout_matrix.svg                    |    1 +
 spec/fixtures/layout_pack.html                     |   38 +
 spec/fixtures/layout_pack.svg                      |    1 +
 spec/fixtures/layout_partition_fill.html           |   40 +
 spec/fixtures/layout_partition_fill.svg            |   32 +
 spec/fixtures/layout_tree_orient_left.html         |   36 +
 spec/fixtures/layout_tree_orient_left.svg          |    1 +
 .../layout_tree_orient_radial_breadth_20.html      |   39 +
 .../layout_tree_orient_radial_breadth_20.svg       |    1 +
 spec/fixtures/layout_tree_orient_top.svg           |    1 +
 spec/fixtures/layout_treemap.svg                   |    1 +
 spec/fixtures/line_interpolation.html              |   63 +
 spec/fixtures/line_interpolation.svg               |    1 +
 spec/fixtures/line_interpolation_segmented.html    |   65 +
 spec/fixtures/line_interpolation_segmented.svg     |    1 +
 spec/fixtures/protovis-r3.3.js                     |  287 +++++
 spec/fixtures/rule-anchor.html                     |   33 +
 spec/fixtures/rule_anchor.svg                      |    1 +
 spec/fixtures/stack-expand.html                    |   41 +
 spec/fixtures/stack-silohouette.html               |   41 +
 spec/fixtures/stack-wiggle.html                    |   41 +
 spec/fixtures/stack_expand.svg                     |    1 +
 spec/fixtures/stack_silohouette.svg                |    1 +
 spec/fixtures/stack_wiggle.svg                     |    1 +
 spec/fixtures/svgscene.html                        |   26 +
 spec/fixtures/tipsy.gif                            |  Bin 0 -> 58 bytes
 spec/fixtures/wedge-anchor.html                    |   33 +
 spec/fixtures/wedge-donut.html                     |   35 +
 spec/fixtures/wedge_anchor.svg                     |    1 +
 spec/fixtures/wedge_donut.svg                      |    1 +
 spec/flatten_spec.rb                               |   47 +
 spec/histogram_spec.rb                             |   28 +
 spec/image_spec.rb                                 |   27 +
 spec/internal_spec.rb                              |  151 +++
 spec/javascript_behaviour_spec.rb                  |   64 +
 spec/label_spec.rb                                 |   41 +
 spec/layout_arc_spec.rb                            |   68 ++
 spec/layout_cluster_spec.rb                        |   53 +
 spec/layout_grid_spec.rb                           |   40 +
 spec/layout_horizon_spec.rb                        |   59 +
 spec/layout_indent_spec.rb                         |   53 +
 spec/layout_matrix_spec.rb                         |   53 +
 spec/layout_pack_spec.rb                           |   49 +
 spec/layout_partition_spec.rb                      |   45 +
 spec/layout_stack_spec.rb                          |  128 ++
 spec/layout_tree_spec.rb                           |   56 +
 spec/layout_treemap_spec.rb                        |   41 +
 spec/line_spec.rb                                  |  189 +++
 spec/mark_spec.rb                                  |   20 +
 spec/nest_spec.rb                                  |   47 +
 spec/panel_spec.rb                                 |   35 +
 spec/readme_spec.rb                                |   38 +
 spec/ruby_api_spec.rb                              |   70 ++
 spec/rule_spec.rb                                  |   33 +
 spec/scale_linear_datetime_spec.rb                 |   56 +
 spec/scale_linear_spec.rb                          |  140 +++
 spec/scale_log_spec.rb                             |  114 ++
 spec/scale_ordinal_spec.rb                         |   85 ++
 spec/scale_spec.rb                                 |    8 +
 spec/spec.opts                                     |    3 +
 spec/spec_helper.rb                                |  249 ++++
 spec/vector_spec.rb                                |   36 +
 spec/wedge_spec.rb                                 |   66 ++
 vendor/protovis/protovis-r3.3.js                   |  287 +++++
 vendor/protovis/src/behavior/Behavior.js           |   32 +
 vendor/protovis/src/behavior/Drag.js               |  112 ++
 vendor/protovis/src/behavior/Pan.js                |  110 ++
 vendor/protovis/src/behavior/Point.js              |  157 +++
 vendor/protovis/src/behavior/Resize.js             |  104 ++
 vendor/protovis/src/behavior/Select.js             |  100 ++
 vendor/protovis/src/behavior/Zoom.js               |   85 ++
 vendor/protovis/src/color/Color.js                 |  598 ++++++++++
 vendor/protovis/src/color/Colors.js                |  135 +++
 vendor/protovis/src/color/Ramp.js                  |   17 +
 vendor/protovis/src/data/Arrays.js                 |  277 +++++
 vendor/protovis/src/data/Dom.js                    |  380 ++++++
 vendor/protovis/src/data/Flatten.js                |  146 +++
 vendor/protovis/src/data/Histogram.js              |  120 ++
 vendor/protovis/src/data/LinearScale.js            |   54 +
 vendor/protovis/src/data/LogScale.js               |  142 +++
 vendor/protovis/src/data/Nest.js                   |  257 ++++
 vendor/protovis/src/data/Numbers.js                |  313 +++++
 vendor/protovis/src/data/Objects.js                |   78 ++
 vendor/protovis/src/data/OrdinalScale.js           |  267 +++++
 vendor/protovis/src/data/QuantileScale.js          |  180 +++
 vendor/protovis/src/data/QuantitativeScale.js      |  440 +++++++
 vendor/protovis/src/data/RootScale.js              |   55 +
 vendor/protovis/src/data/Scale.js                  |   86 ++
 vendor/protovis/src/data/Transform.js              |  109 ++
 vendor/protovis/src/data/Tree.js                   |  124 ++
 vendor/protovis/src/data/Vector.js                 |  118 ++
 vendor/protovis/src/geo/Geo.js                     |    5 +
 vendor/protovis/src/geo/GeoScale.js                |  307 +++++
 vendor/protovis/src/geo/LatLng.js                  |   23 +
 vendor/protovis/src/geo/Projection.js              |   43 +
 vendor/protovis/src/geo/Projections.js             |  117 ++
 vendor/protovis/src/lang/Array.js                  |  112 ++
 vendor/protovis/src/lang/init.js                   |   26 +
 vendor/protovis/src/layout/Arc.js                  |  178 +++
 vendor/protovis/src/layout/Bullet.js               |  164 +++
 vendor/protovis/src/layout/Cluster.js              |  205 ++++
 vendor/protovis/src/layout/Force.js                |  309 +++++
 vendor/protovis/src/layout/Grid.js                 |  119 ++
 vendor/protovis/src/layout/Hierarchy.js            |  249 ++++
 vendor/protovis/src/layout/Horizon.js              |  159 +++
 vendor/protovis/src/layout/Indent.js               |   83 ++
 vendor/protovis/src/layout/Layout.js               |   56 +
 vendor/protovis/src/layout/Matrix.js               |  177 +++
 vendor/protovis/src/layout/Network.js              |  302 +++++
 vendor/protovis/src/layout/Pack.js                 |  323 +++++
 vendor/protovis/src/layout/Partition.js            |  203 ++++
 vendor/protovis/src/layout/Rollup.js               |  203 ++++
 vendor/protovis/src/layout/Stack.js                |  391 +++++++
 vendor/protovis/src/layout/Tree.js                 |  282 +++++
 vendor/protovis/src/layout/Treemap.js              |  347 ++++++
 vendor/protovis/src/mark/Anchor.js                 |   81 ++
 vendor/protovis/src/mark/Area.js                   |  268 +++++
 vendor/protovis/src/mark/Bar.js                    |   93 ++
 vendor/protovis/src/mark/Dot.js                    |  212 ++++
 vendor/protovis/src/mark/Ease.js                   |  150 +++
 vendor/protovis/src/mark/Image.js                  |  154 +++
 vendor/protovis/src/mark/Label.js                  |  155 +++
 vendor/protovis/src/mark/Line.js                   |  195 +++
 vendor/protovis/src/mark/Mark.js                   | 1237 ++++++++++++++++++++
 vendor/protovis/src/mark/Panel.js                  |  273 +++++
 vendor/protovis/src/mark/Rule.js                   |  143 +++
 vendor/protovis/src/mark/Transient.js              |    7 +
 vendor/protovis/src/mark/Transition.js             |  195 +++
 vendor/protovis/src/mark/Wedge.js                  |  244 ++++
 vendor/protovis/src/physics/BoundConstraint.js     |   75 ++
 vendor/protovis/src/physics/ChargeForce.js         |  184 +++
 vendor/protovis/src/physics/CollisionConstraint.js |  113 ++
 vendor/protovis/src/physics/Constraint.js          |   26 +
 vendor/protovis/src/physics/DragForce.js           |   49 +
 vendor/protovis/src/physics/Force.js               |   25 +
 vendor/protovis/src/physics/Particle.js            |   81 ++
 vendor/protovis/src/physics/PositionConstraint.js  |   72 ++
 vendor/protovis/src/physics/Quadtree.js            |  195 +++
 vendor/protovis/src/physics/Simulation.js          |  159 +++
 vendor/protovis/src/physics/SpringForce.js         |  141 +++
 vendor/protovis/src/pv-internals.js                |  154 +++
 vendor/protovis/src/pv.js                          |   95 ++
 vendor/protovis/src/scene/SvgArea.js               |  172 +++
 vendor/protovis/src/scene/SvgBar.js                |   28 +
 vendor/protovis/src/scene/SvgCurve.js              |  354 ++++++
 vendor/protovis/src/scene/SvgDot.js                |   81 ++
 vendor/protovis/src/scene/SvgImage.js              |   45 +
 vendor/protovis/src/scene/SvgLabel.js              |   46 +
 vendor/protovis/src/scene/SvgLine.js               |  159 +++
 vendor/protovis/src/scene/SvgPanel.js              |  126 ++
 vendor/protovis/src/scene/SvgRule.js               |   26 +
 vendor/protovis/src/scene/SvgScene.js              |  185 +++
 vendor/protovis/src/scene/SvgWedge.js              |   66 ++
 vendor/protovis/src/text/DateFormat.js             |  262 +++++
 vendor/protovis/src/text/Format.js                 |   78 ++
 vendor/protovis/src/text/NumberFormat.js           |  227 ++++
 vendor/protovis/src/text/TimeFormat.js             |  115 ++
 web/Rakefile                                       |   53 +
 web/build_site.rb                                  |  108 ++
 web/examples.haml                                  |   35 +
 web/index.haml                                     |  121 ++
 web/style.css                                      |   82 ++
 298 files changed, 34649 insertions(+)

diff --git a/.gemtest b/.gemtest
new file mode 100644
index 0000000..e69de29
diff --git a/History.txt b/History.txt
new file mode 100644
index 0000000..2cf5447
--- /dev/null
+++ b/History.txt
@@ -0,0 +1,177 @@
+=== 0.5.2 / 2012-07-21
+
+- Fixed image bug (#13), and updated example for image. Web creation is updated, too
+- Fixed logCeil on quantitative.rb:362
+  
+=== 0.5.1 / 2011-11-19
++ Implemented subdivisions on Scale::Log.ticks() 
+* Implemented test for issue #7 
+- Fixed bug on Scale::Quantitative.ticks() when domain is [a,a]
+- Fixed bug on SvgScene.title
+- Merge pull request #11 from mohawkjohn/tag_name_fix [mohawkjohn]
+- Fixed typo in 'height' on Mark::Area [mohawkjohn]
+- Fixed precision problem on SvgScene.path_join spec and error on one of median test on jruby
+- workaround for nokogiri-java null pointer exception [subdbp]
+
+=== 0.5.0 / 2011-02-04
+* Nokogiri used as XML builder. Fall back to REXML if nokogiri is not available or $rubyvis_no_nokogiri=true
+
+
+=== 0.4.1 / 2011-01-26
+* All tests run on ruby 1.8.7. Not all pass, because on ruby<1.9 hash order are not preserved
+* Removed warnings for Ruby 1.9+
+* Changed SvgScene.implicit and Color.names with constants
+* Bug fix: Examples crashes on Ruby 1.9.3 because names of files are freezed and REXML try to change it
+
+=== 0.4.0 / 2011-01-03
+
+Massive bug fix. Please, update ASAP
+
+* Implemented Vector, used on segmented lines
+* Bug fix: Segmented areas with basis, cardinal and monotone interpolation was parsed using linear interpolation
+* Bug fix: Incorrect color when using hsl with decimal h 
+* Bug fix: Segmented areas doesn't change color
+* Bug fix: Wedge without inner radius return incorrect path
+* Bug fix: Stack layout with 'inside-out' order crash.
+* Bug fix: Incorrect marks properties evaluation order
+* Bug fix: Segmented lines raises an Exception
+* New specs: Flatten, Grid, Dot, Vector, Rule, Cluster, Partition, Wedge, Indent, Tree, Treemap
+* Improved specs: Area, Line, Panel
+* Deleted dependence of Rubyvis.document. Each panel without parent have an independent REXML::Document
+
+=== 0.3.6 / 2010-12-28
+
+* Matrix layout implemented. Example and spec available.
+* Added spec for Layout::Arc
+
+=== 0.3.5 / 2010-12-20
+
+* Horizon and Arc layouts implemented
+* Bug fix: Error on Layout::Stack spec
+* Bug fix: Inconsistent behaviour of Rubyvis.color and Rubyvis::Hsl
+* Bug fix: Rubyvis::Color.color fails on ruby 1.8.7
+* Bug fix: Raise error with negative number on Format.format
+
+=== 0.3.4 / 2010-12-11
+
+* Implemented Layout::Grid and Layout::Tree
+* New example: census treemap. Added spec for layout
+* Examples reordered
+* Bug fix: Area with 0 on height create infinite loop
+* Bug fix: Layout::Pack overlaps circles on NE position
+
+=== 0.3.3 / 2010-11-23
+
+* Implemented Rubyvis::Layout::Pack, Rubyvis::Layout::Indent and Rubyvis::Flatten
+* Implemeted Rubyvis::Mark.title()
+* New examples: bubble charts and circle packing
+* Better documentation for Network
+
+=== 0.3.2 / 2010-11-23
+
+* Updated examples
+* Added Layout::Cluster and dendogram example
+
+=== 0.3.1 / 2010-11-19
+
+* Added Layout::Partition
+* Added Rubyvis::Histogram
+* Added sunburst and icicle example
+* Added shortcuts methods for layouts
+* Bug fix on Hierarchy
+* Updated README and Histogram spec
+
+=== 0.3.0 / 2010-11-17
+* Network and Hierarchy classes on module Layout implemented. Require testing
+* Rubyvis::Layout::Treemap fully operational
+* Rubyvis::Dom almost complete, including spec
+* Mark.extend changed to Mark.mark_extend, to avoid clashes with ruby extend
+* Bug fix: Rubyvis::Dom::Node.sort doesn't set first_child and last_child correctly
+* Updated for hoe 1.7.0
+* Updated example of coordinate parallels
+* New example: treemap/treemap.rb
+
+=== 0.2.2 / 2010-11-13
+
+* Updated to rspec 2. Bug fix: instance_eval raises an error on js_apply
+* Updated antibiotics example
+* Tested on 1.8.7, 1.9.1, 1.9.2 and svn-head.
+
+=== 0.2.1 / 2010-11-11
+
+* Added Rubyvis.dict() 
+* Added Rubyvis::Scale::Ordinal.split_flush()
+* New example: parallel coordinates on /examples/cars/cars.rb
+* New example: pie chart on /examples/antibiotics/antibiotics_wedge.rb
+* New spec for readme examples (sort of smoke test)
+* Better implementation of Layout
+* Bug fix: raise error Proc.js_apply on Ruby1.9.2 (doesn't accept instance_eval with &proc)
+* Ahhh... how I hate differences on return inside lambdas! Resolved bug on AreaPrototype::area_build_instance removing return inside a lambda
+* Bug fix: Rubyvis::Scale::Linear.scale() returns a value when nil is passed. Now, returns nil 
+* Bug fix: Calling Mark.instance() of a parent mark inside a children returns only the last instance, not the currently parsed instance
+
+
+=== 0.2.0 / 2010-11-02
+
+* IMPORTANT: Added 'ruby best practices' API. See README and examples/first_rbp_api.rb to learn how to use
+* Added width and height explicitly on examples pages. 
+* Added examples for interpolation on lines and areas
+* Fixed interpolate for lines and areas. 
+* New spec for Line and Area spec.  
+* Added spec for numeric tick_format
+* Added documentation for Rubyvis::Colors, Rubyvis::Color and Rubyvis::Line
+* Bug fix: interpolate "step-after", "step-before" and "basis" on Area marks doesn't work Spec for Area marks
+* Changed API_VERSION for PROTOVIS_API_VERSION
+
+=== 0.1.7 / 2010-10-31
+
+* Added image support
+
+=== 0.1.6 / 2010-10-30
+
+* Improved documentation for examples. Added description from protovis site on the one borrowed from it and added commentary on new ones.
+* Distribution includes 'web' directory, with script to recreate the web site. Use as example of massive creation of graphics
+* Added explicitily "none" to  svg "fill" property. This allows to render properly with librsv (rsgv), without affecting the browser output
+* Added API documentation on many files.
+* Replaced all pv instances on code for Rubyvis
+
+=== 0.1.5 / 2010-10-22
+
+* Bug fix: styles considered properly, so font attribute works right now.
+* Bug fix: anchors have proper parent assignation.
+
+=== 0.1.4 / 2010-10-20
+
+* Bug fix: Order now works on Nest
+* Added log scale spec. domain, range, scale, invert and ticks works like javascript version
+* First stack layout version operational
+* Added grouped and stacked chart examples
+
+
+=== 0.1.3 / 2010-10-08
+
+* New Wedge and  Dot mark
+* New Log scale and Nest. 
+* Area mark working. 
+* Automatic color scales doesn't work on every ocasion, yet
+* Color, Format::Number and Quantitative fixed. 
+* Fixed attributes works as expected (damn c like 0=false)
+* Added examples (antibiotics and barley)
+* Bug fix: right anchor doesn't affect labels.
+* Crimea grouped bars works. Ordinal scales operational
+
+=== 0.1.2 / 2010-10-04
+
+* Bug fix: SvgScene.panel only parse first element. Crimea-line example works (almost) as expected
+* Support for lines as anchors (not tested, yet)
+* Support for scales using Time class
+* Deleted unnecesary files from protovis
+
+=== 0.1.1 / 2010-10-02
+
+* Operational implementation of Panel, Bar, Rule, Line and Label. Anchor doesn't work, yet [clbustos]
+* Updated README.txt
+
+=== 0.1.0 / 2010-09-30
+
+* First (barely) operational version. See examples/first.rb and examples/second.rb 
diff --git a/Manifest.txt b/Manifest.txt
new file mode 100644
index 0000000..94117ee
--- /dev/null
+++ b/Manifest.txt
@@ -0,0 +1,296 @@
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+examples/1_basic/1a_bar_rbp_api.rb
+examples/1_basic/1b_bar_pv_api.rb
+examples/1_basic/2_bar_and_rule.rb
+examples/1_basic/3_grouped_bars.rb
+examples/1_basic/area_interpolation.rb
+examples/1_basic/dot.rb
+examples/1_basic/fixtures/tipsy.gif
+examples/1_basic/grid.rb
+examples/1_basic/image.rb
+examples/1_basic/line.rb
+examples/1_basic/line_interpolation.rb
+examples/2_medium/censo_agropecuario/censo_agropecuario_chile_data.rb
+examples/2_medium/censo_agropecuario/census_treemap.rb
+examples/2_medium/censo_agropecuario/create_data.rb
+examples/2_medium/censo_agropecuario/resultset.csv
+examples/2_medium/horizon.rb
+examples/2_medium/nested_grid.rb
+examples/3_pv_conventional/area.rb
+examples/3_pv_conventional/bar_column_chart.rb
+examples/3_pv_conventional/grouped_charts.rb
+examples/3_pv_conventional/line_and_step.rb
+examples/3_pv_conventional/pie_and_donut.rb
+examples/3_pv_conventional/scatterplot.rb
+examples/3_pv_conventional/stacked_charts.rb
+examples/4_pv_custom/antibiotics/antibiotics_data.rb
+examples/4_pv_custom/antibiotics/antibiotics_scatter.rb
+examples/4_pv_custom/antibiotics/antibiotics_wedge.rb
+examples/4_pv_custom/barley/barley.rb
+examples/4_pv_custom/barley/barley_data.rb
+examples/4_pv_custom/cars/cars.rb
+examples/4_pv_custom/cars/cars_data.rb
+examples/4_pv_custom/crimea/crimea_data.rb
+examples/4_pv_custom/crimea/crimea_grouped_bar.rb
+examples/4_pv_custom/crimea/crimea_line.rb
+examples/5_pv_hierarchies/bubble_charts.rb
+examples/5_pv_hierarchies/bubble_charts_matrix.rb
+examples/5_pv_hierarchies/circle_packing.rb
+examples/5_pv_hierarchies/dendogram.rb
+examples/5_pv_hierarchies/icicle.rb
+examples/5_pv_hierarchies/indent.rb
+examples/5_pv_hierarchies/node_link_tree.rb
+examples/5_pv_hierarchies/sunburst.rb
+examples/5_pv_hierarchies/treemap.rb
+examples/6_pv_networks/arc.rb
+examples/6_pv_networks/matrix.rb
+examples/6_pv_networks/miserables_data.rb
+lib/rubyvis.rb
+lib/rubyvis/color/color.rb
+lib/rubyvis/color/colors.rb
+lib/rubyvis/dom.rb
+lib/rubyvis/flatten.rb
+lib/rubyvis/format.rb
+lib/rubyvis/format/date.rb
+lib/rubyvis/format/number.rb
+lib/rubyvis/histogram.rb
+lib/rubyvis/internals.rb
+lib/rubyvis/javascript_behaviour.rb
+lib/rubyvis/layout.rb
+lib/rubyvis/layout/arc.rb
+lib/rubyvis/layout/cluster.rb
+lib/rubyvis/layout/grid.rb
+lib/rubyvis/layout/hierarchy.rb
+lib/rubyvis/layout/horizon.rb
+lib/rubyvis/layout/indent.rb
+lib/rubyvis/layout/matrix.rb
+lib/rubyvis/layout/network.rb
+lib/rubyvis/layout/pack.rb
+lib/rubyvis/layout/partition.rb
+lib/rubyvis/layout/stack.rb
+lib/rubyvis/layout/tree.rb
+lib/rubyvis/layout/treemap.rb
+lib/rubyvis/mark.rb
+lib/rubyvis/mark/anchor.rb
+lib/rubyvis/mark/area.rb
+lib/rubyvis/mark/bar.rb
+lib/rubyvis/mark/dot.rb
+lib/rubyvis/mark/image.rb
+lib/rubyvis/mark/label.rb
+lib/rubyvis/mark/line.rb
+lib/rubyvis/mark/panel.rb
+lib/rubyvis/mark/rule.rb
+lib/rubyvis/mark/shorcut_methods.rb
+lib/rubyvis/mark/wedge.rb
+lib/rubyvis/nest.rb
+lib/rubyvis/property.rb
+lib/rubyvis/scale.rb
+lib/rubyvis/scale/linear.rb
+lib/rubyvis/scale/log.rb
+lib/rubyvis/scale/ordinal.rb
+lib/rubyvis/scale/quantitative.rb
+lib/rubyvis/scene/svg_area.rb
+lib/rubyvis/scene/svg_bar.rb
+lib/rubyvis/scene/svg_curve.rb
+lib/rubyvis/scene/svg_dot.rb
+lib/rubyvis/scene/svg_image.rb
+lib/rubyvis/scene/svg_label.rb
+lib/rubyvis/scene/svg_line.rb
+lib/rubyvis/scene/svg_panel.rb
+lib/rubyvis/scene/svg_rule.rb
+lib/rubyvis/scene/svg_scene.rb
+lib/rubyvis/scene/svg_wedge.rb
+lib/rubyvis/sceneelement.rb
+lib/rubyvis/transform.rb
+lib/rubyvis/vector.rb
+spec/anchor_spec.rb
+spec/area_spec.rb
+spec/bar_spec.rb
+spec/color_spec.rb
+spec/dom_spec.rb
+spec/dot_spec.rb
+spec/fixtures/anchor.html
+spec/fixtures/anchor.svg
+spec/fixtures/area-segmented.html
+spec/fixtures/area_interpolation.html
+spec/fixtures/area_interpolation.svg
+spec/fixtures/area_segmented.svg
+spec/fixtures/dot-anchor.html
+spec/fixtures/dot_anchor.svg
+spec/fixtures/image.svg
+spec/fixtures/layers.js
+spec/fixtures/layout_arc.svg
+spec/fixtures/layout_cluster.html
+spec/fixtures/layout_cluster.svg
+spec/fixtures/layout_cluster_left_group_2.html
+spec/fixtures/layout_cluster_left_group_2.svg
+spec/fixtures/layout_grid.html
+spec/fixtures/layout_grid.svg
+spec/fixtures/layout_horizon.svg
+spec/fixtures/layout_indent.html
+spec/fixtures/layout_indent.svg
+spec/fixtures/layout_matrix.svg
+spec/fixtures/layout_pack.html
+spec/fixtures/layout_pack.svg
+spec/fixtures/layout_partition_fill.html
+spec/fixtures/layout_partition_fill.svg
+spec/fixtures/layout_tree_orient_left.html
+spec/fixtures/layout_tree_orient_left.svg
+spec/fixtures/layout_tree_orient_radial_breadth_20.html
+spec/fixtures/layout_tree_orient_radial_breadth_20.svg
+spec/fixtures/layout_tree_orient_top.svg
+spec/fixtures/layout_treemap.svg
+spec/fixtures/line_interpolation.html
+spec/fixtures/line_interpolation.svg
+spec/fixtures/line_interpolation_segmented.html
+spec/fixtures/line_interpolation_segmented.svg
+spec/fixtures/protovis-r3.3.js
+spec/fixtures/rule-anchor.html
+spec/fixtures/rule_anchor.svg
+spec/fixtures/stack-expand.html
+spec/fixtures/stack-silohouette.html
+spec/fixtures/stack-wiggle.html
+spec/fixtures/stack_expand.svg
+spec/fixtures/stack_silohouette.svg
+spec/fixtures/stack_wiggle.svg
+spec/fixtures/svgscene.html
+spec/fixtures/tipsy.gif
+spec/fixtures/wedge-anchor.html
+spec/fixtures/wedge-donut.html
+spec/fixtures/wedge_anchor.svg
+spec/fixtures/wedge_donut.svg
+spec/flatten_spec.rb
+spec/histogram_spec.rb
+spec/image_spec.rb
+spec/internal_spec.rb
+spec/javascript_behaviour_spec.rb
+spec/label_spec.rb
+spec/layout_arc_spec.rb
+spec/layout_cluster_spec.rb
+spec/layout_grid_spec.rb
+spec/layout_horizon_spec.rb
+spec/layout_indent_spec.rb
+spec/layout_matrix_spec.rb
+spec/layout_pack_spec.rb
+spec/layout_partition_spec.rb
+spec/layout_stack_spec.rb
+spec/layout_tree_spec.rb
+spec/layout_treemap_spec.rb
+spec/line_spec.rb
+spec/mark_spec.rb
+spec/nest_spec.rb
+spec/panel_spec.rb
+spec/readme_spec.rb
+spec/ruby_api_spec.rb
+spec/rule_spec.rb
+spec/scale_linear_datetime_spec.rb
+spec/scale_linear_spec.rb
+spec/scale_log_spec.rb
+spec/scale_ordinal_spec.rb
+spec/scale_spec.rb
+spec/spec.opts
+spec/spec_helper.rb
+spec/vector_spec.rb
+spec/wedge_spec.rb
+vendor/protovis/protovis-r3.3.js
+vendor/protovis/src/behavior/Behavior.js
+vendor/protovis/src/behavior/Drag.js
+vendor/protovis/src/behavior/Pan.js
+vendor/protovis/src/behavior/Point.js
+vendor/protovis/src/behavior/Resize.js
+vendor/protovis/src/behavior/Select.js
+vendor/protovis/src/behavior/Zoom.js
+vendor/protovis/src/color/Color.js
+vendor/protovis/src/color/Colors.js
+vendor/protovis/src/color/Ramp.js
+vendor/protovis/src/data/Arrays.js
+vendor/protovis/src/data/Dom.js
+vendor/protovis/src/data/Flatten.js
+vendor/protovis/src/data/Histogram.js
+vendor/protovis/src/data/LinearScale.js
+vendor/protovis/src/data/LogScale.js
+vendor/protovis/src/data/Nest.js
+vendor/protovis/src/data/Numbers.js
+vendor/protovis/src/data/Objects.js
+vendor/protovis/src/data/OrdinalScale.js
+vendor/protovis/src/data/QuantileScale.js
+vendor/protovis/src/data/QuantitativeScale.js
+vendor/protovis/src/data/RootScale.js
+vendor/protovis/src/data/Scale.js
+vendor/protovis/src/data/Transform.js
+vendor/protovis/src/data/Tree.js
+vendor/protovis/src/data/Vector.js
+vendor/protovis/src/geo/Geo.js
+vendor/protovis/src/geo/GeoScale.js
+vendor/protovis/src/geo/LatLng.js
+vendor/protovis/src/geo/Projection.js
+vendor/protovis/src/geo/Projections.js
+vendor/protovis/src/lang/Array.js
+vendor/protovis/src/lang/init.js
+vendor/protovis/src/layout/Arc.js
+vendor/protovis/src/layout/Bullet.js
+vendor/protovis/src/layout/Cluster.js
+vendor/protovis/src/layout/Force.js
+vendor/protovis/src/layout/Grid.js
+vendor/protovis/src/layout/Hierarchy.js
+vendor/protovis/src/layout/Horizon.js
+vendor/protovis/src/layout/Indent.js
+vendor/protovis/src/layout/Layout.js
+vendor/protovis/src/layout/Matrix.js
+vendor/protovis/src/layout/Network.js
+vendor/protovis/src/layout/Pack.js
+vendor/protovis/src/layout/Partition.js
+vendor/protovis/src/layout/Rollup.js
+vendor/protovis/src/layout/Stack.js
+vendor/protovis/src/layout/Tree.js
+vendor/protovis/src/layout/Treemap.js
+vendor/protovis/src/mark/Anchor.js
+vendor/protovis/src/mark/Area.js
+vendor/protovis/src/mark/Bar.js
+vendor/protovis/src/mark/Dot.js
+vendor/protovis/src/mark/Ease.js
+vendor/protovis/src/mark/Image.js
+vendor/protovis/src/mark/Label.js
+vendor/protovis/src/mark/Line.js
+vendor/protovis/src/mark/Mark.js
+vendor/protovis/src/mark/Panel.js
+vendor/protovis/src/mark/Rule.js
+vendor/protovis/src/mark/Transient.js
+vendor/protovis/src/mark/Transition.js
+vendor/protovis/src/mark/Wedge.js
+vendor/protovis/src/physics/BoundConstraint.js
+vendor/protovis/src/physics/ChargeForce.js
+vendor/protovis/src/physics/CollisionConstraint.js
+vendor/protovis/src/physics/Constraint.js
+vendor/protovis/src/physics/DragForce.js
+vendor/protovis/src/physics/Force.js
+vendor/protovis/src/physics/Particle.js
+vendor/protovis/src/physics/PositionConstraint.js
+vendor/protovis/src/physics/Quadtree.js
+vendor/protovis/src/physics/Simulation.js
+vendor/protovis/src/physics/SpringForce.js
+vendor/protovis/src/pv-internals.js
+vendor/protovis/src/pv.js
+vendor/protovis/src/scene/SvgArea.js
+vendor/protovis/src/scene/SvgBar.js
+vendor/protovis/src/scene/SvgCurve.js
+vendor/protovis/src/scene/SvgDot.js
+vendor/protovis/src/scene/SvgImage.js
+vendor/protovis/src/scene/SvgLabel.js
+vendor/protovis/src/scene/SvgLine.js
+vendor/protovis/src/scene/SvgPanel.js
+vendor/protovis/src/scene/SvgRule.js
+vendor/protovis/src/scene/SvgScene.js
+vendor/protovis/src/scene/SvgWedge.js
+vendor/protovis/src/text/DateFormat.js
+vendor/protovis/src/text/Format.js
+vendor/protovis/src/text/NumberFormat.js
+vendor/protovis/src/text/TimeFormat.js
+web/Rakefile
+web/build_site.rb
+web/examples.haml
+web/index.haml
+web/style.css
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..95e958d
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,155 @@
+= Rubyvis
+
+* http://rubyvis.rubyforge.org/
+
+== DESCRIPTION:
+
+Ruby port of Protovis[http://vis.stanford.edu/protovis/], a Javascript visualization toolkit.
+
+== FEATURES/PROBLEMS:
+
+This library implements almost completely core API of protovis, including all static marks, SVG builder class and data classes. Spec coverage is near 90%
+
+Implemented: 
+
+* Marks: All, except transient and transitions.
+* Layout: Arc, Cluster, Grid, Horizon, Indent, Matrix, Pack, Partition, Stack, Tree and Treemap. To implement: Bullet, Force, and Rollup.
+
+Using protovis examples[http://vis.stanford.edu/protovis/ex/] as reference
+
+* Conventional: All working
+* Custom: 
+ * Backer's Barley
+ * Burtin's Antibiotics: Scatterplot matrix
+ * Cars: Parallel Coordinates
+ * Crimea war: Grouped bar chart and line chart
+* Hierarchies:
+ * Treemap
+ * Bubble Charts
+ * Circle Packing
+ * Dendogram
+ * Icicle
+ * Indent
+ * Node-Link Tree
+ * Sunburst
+ * Treemap
+* Networks:
+ * Arc
+ * Matrix
+ 
+I try to maintain, when posible, complete compatibility with Javascript API, including camel case naming of functions. Johnson [http://github.com/jbarnette/johnson] - the lovely Javascript wrapper inside Ruby embrace - is our friend to test implementation of basic object. 
+
+User could use +pv+ freely, cause is defined as a global method which call Rubyvis.
+
+Nokogiri is used as XML library. If not available, or $rubyvis_no_nokogiri is set to true, REXML is used. Nokogiri is 30%-35% faster that REXML on our test.
+
+== CURRENT PROGRESS
+
+* pv.js
+* pv-internals.js
+* color/Color.js
+* color/Colors.js
+* data/Arrays.js
+* data/Flatten.js
+* data/Histogram.js
+* data/Numbers.js
+* data/LinearScale.js
+* data/LogScale.js (incomplete)
+* data/Nest.js
+* data/QuantitativeScale.js
+* data/OrdinalScale.js
+* data/Scale.js
+* layout/Arc.js
+* layout/Cluster.js
+* layout/Grid.js
+* layout/Hierarchy.js
+* layout/Horizon.js
+* layout/Indent.js
+* layout/Layout.js
+* layout/Matrix.js
+* layout/Network.js
+* layout/Pack.js
+* layout/Partition.js
+* layout/Stack.js
+* layout/Tree.js
+* layout/Treemap.js
+* mark/Anchor.js
+* mark/Area.js
+* mark/Bar.js 
+* mark/Dot.js 
+* mark/Label.js
+* mark/Line.js
+* mark/Mark.js
+* mark/Panel.js
+* mark/Rule.js
+* mark/Wedge.js
+* scene/SvgBar.js
+* scene/SvgLabel.js
+* scene/SvgLine.js
+* scene/SvgPanel.js
+* scene/SvgRule.js
+* scene/SvgScene.js
+* scene/SvgWedge.js
+* text/Format.js (incomplete)
+* text/NumberFormat.js (incomplete)
+
+== SYNOPSIS:
+
+The primary API, based on Gregory Brown's Ruby Best Practices, uses blocks and name of marks as methods
+
+    require 'rubyvis'
+    
+    vis = Rubyvis::Panel.new do 
+      width 150
+      height 150
+      bar do
+        data [1, 1.2, 1.7, 1.5, 0.7, 0.3]
+        width 20
+        height {|d| d * 80}
+        bottom(0)
+        left {index * 25}
+      end
+    end
+    
+    vis.render
+    puts vis.to_svg
+
+
+The library allows you to use chain methods API, like original protovis
+
+    require 'rubyvis'
+    
+    vis = Rubyvis::Panel.new.width(150).height(150);
+    
+    vis.add(pv.Bar).
+      data([1, 1.2, 1.7, 1.5, 0.7, 0.3]).
+      width(20).
+      height(lambda {|d| d * 80}).
+      bottom(0).
+      left(lambda {self.index * 25});
+    
+    vis.render
+    puts vis.to_svg
+    
+
+See examples directory for original protovis examples adaptations and others graphics
+
+== THE MOST FREQUENT QUESTION (MFQ)
+
+¿Why use a server-side technology if I can use a client-side, which is faster and more economic for developer?
+
+If you want to present graphs: (a) complex and/or dynamically generated, (b) only on the web and (c) on modern browsers, Protovis[http://vis.stanford.edu/protovis/] is an excellent option. For simpler charts, Protovis is overkill. I recomend jqPlot[http://www.jqplot.com/]
+
+Rubyvis is designed mainly for off-line operation, like batch creation of graphs for use on printed documents (rtf-pdf), with possibility of use easily the script for on-line use.
+
+== REQUIREMENTS:
+
+Tested on Ruby 1.8.7, 1.9.1, 1.9.2-p0 and ruby-head (future 1.9.3)
+
+== INSTALL:
+
+$ gem install rubyvis
+
+== LICENSE:
+
+GPL-2
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..9322ab8
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,38 @@
+# -*- ruby -*-
+$:.unshift(File.expand_path(File.dirname(__FILE__)+"/lib"))
+$:.unshift(File.expand_path(File.dirname(__FILE__)))
+
+require 'rubygems'
+require 'hoe'
+require 'rubyvis'
+require 'rspec'
+require 'rspec/core/rake_task'
+require 'rubyforge'
+
+Hoe.plugin :git
+
+h=Hoe.spec 'rubyvis' do
+  self.testlib=:rspec
+  self.rspec_options << "-c" << "-b"
+  self.developer('Claudio Bustos', 'clbustos_at_gmail.com')
+  self.version=Rubyvis::VERSION
+  self.extra_dev_deps << ["coderay",">=0"] << ["haml",">=0"] << ["nokogiri", ">=0"] << ["rspec",">=2.0"] << ["RedCloth",">=0"]
+end
+desc "Publicar docs en rubyforge"
+task :publicar_docs => [:clean, :docs] do
+  #ruby %{agregar_adsense_a_doc.rb}
+  path = File.expand_path("~/.rubyforge/user-config.yml")
+  config = YAML.load(File.read(path))
+  host = "#{config["username"]}@rubyforge.org"
+  
+  remote_dir = "/var/www/gforge-projects/#{h.rubyforge_name}/#{h.remote_rdoc_dir
+  }"
+  local_dir = h.local_rdoc_dir
+  Dir.glob(local_dir+"/**/*") {|file|
+    sh %{chmod 755 #{file}}
+  }
+  sh %{rsync #{h.rsync_args} #{local_dir}/ #{host}:#{remote_dir}}
+end
+
+
+# vim: syntax=ruby
diff --git a/examples/1_basic/1a_bar_rbp_api.rb b/examples/1_basic/1a_bar_rbp_api.rb
new file mode 100644
index 0000000..fb191f3
--- /dev/null
+++ b/examples/1_basic/1a_bar_rbp_api.rb
@@ -0,0 +1,21 @@
+# = First example (RBP API)
+# This is the RBP API version of "Getting Started" example of Protovis introduction.
+# On this example we  build a bar chart using panel and bar marks.
+# A mark represents a set of graphical elements that share data and visual encodings. Although marks are simple by themselves, you can combine them in interesting ways to make rich, interactive visualizations
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+    
+vis = Rubyvis::Panel.new do 
+  width 150
+  height 150
+  bar do
+    data [1, 1.2, 1.7, 1.5, 0.7, 0.3]
+    width 20
+    height {|d| d * 80}
+    bottom(0)
+    left {index * 25}
+  end
+end
+
+vis.render
+puts vis.to_svg
diff --git a/examples/1_basic/1b_bar_pv_api.rb b/examples/1_basic/1b_bar_pv_api.rb
new file mode 100644
index 0000000..0ae3e2d
--- /dev/null
+++ b/examples/1_basic/1b_bar_pv_api.rb
@@ -0,0 +1,16 @@
+# = First example (Protovis API)
+# This is the protovis API version of "Getting Started" example of Protovis introduction.
+# On this example we  build a bar chart using panel and bar marks.
+# A mark represents a set of graphical elements that share data and visual encodings. Although marks are simple by themselves, you can combine them in interesting ways to make rich, interactive visualizations
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+vis = Rubyvis::Panel.new.width(150).height(150);
+
+vis.add(pv.Bar).data([1, 1.2, 1.7, 1.5, 0.7, 0.3]).
+  width(20).
+  height(lambda {|d| d * 80}).
+  bottom(0).
+  left(lambda {index * 25})
+
+vis.render()
+puts vis.to_svg
diff --git a/examples/1_basic/2_bar_and_rule.rb b/examples/1_basic/2_bar_and_rule.rb
new file mode 100644
index 0000000..5b64e3b
--- /dev/null
+++ b/examples/1_basic/2_bar_and_rule.rb
@@ -0,0 +1,28 @@
+# = Inheritance and labels
+# Second example of Protovis "Getting Started section"
+# The rule's label inherits the data and bottom property, causing it to appear on the rule and render the value (datum) as text. The bar’s label uses the bottom anchor to tweak positioning, so that the label is centered at the bottom of the bar. 
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+vis = pv.Panel.new()
+.width(150)
+.height(200)
+
+vis.add(pv.Rule).
+  data(pv.range(0, 2, 0.5)).
+  bottom(lambda {|d| d * 80 + 0.5}).
+  add(pv.Label).left(0)
+
+
+vis.add(pv.Bar).
+  data([1, 1.2, 1.7, 1.5, 0.7]).
+  width(20).height(lambda {|d|  d * 80}).
+  bottom(0).
+  left(lambda { index * 25 + 25}).
+  anchor('bottom').
+    add(pv.Label)
+
+
+vis.render();
+puts vis.to_svg
+
diff --git a/examples/1_basic/3_grouped_bars.rb b/examples/1_basic/3_grouped_bars.rb
new file mode 100644
index 0000000..9869ec3
--- /dev/null
+++ b/examples/1_basic/3_grouped_bars.rb
@@ -0,0 +1,23 @@
+# = Using parent
+# This example shows how to group bars on groups and use the parent property to identify and color them
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+vis = pv.Panel.new().width(200).height(150);
+
+bar= vis.add(pv.Panel).data(["a","b","c","d"]).add(pv.Bar)
+    .data([1,2])
+    .width(20)
+    .height(lambda {60+parent.index*20+index*5})
+    .bottom(0)
+    .left(lambda {|d,t| parent.index*60+index*25})
+    
+ bar.anchor("bottom").add(pv.Label).
+   text(lambda {|d,t| "#{t}-#{d}"})
+ bar.anchor("top").add(pv.Label).
+   text(lambda {"#{parent.index}-#{index}"})
+    
+    
+vis.render()
+#puts vis.children_inspect
+puts vis.to_svg
diff --git a/examples/1_basic/area_interpolation.rb b/examples/1_basic/area_interpolation.rb
new file mode 100644
index 0000000..2c2a77b
--- /dev/null
+++ b/examples/1_basic/area_interpolation.rb
@@ -0,0 +1,63 @@
+# = Area Interpolation
+# This example show the 5 types of interpolation available for areas:
+# * linear
+# * step-before
+# * step-after
+# * basis
+# * cardinal
+# 
+# See also "Line Interpolation":line_interpolation.html
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+data = Rubyvis.range(0, 10, 0.5).map {|x| 
+  OpenStruct.new({:x=> x, :y=> Math.sin(x) + 2+rand()*0.3})
+}
+
+p_w=200
+p_h=150
+#p data
+w = 20+p_w*2
+h = 20+p_h*3
+
+x = Rubyvis.Scale.linear(data, lambda {|d| d.x}).range(0, p_w-30)
+y = Rubyvis.Scale.linear(data, lambda {|d| d.y}).range(0, p_h-20);
+interpolations=["linear","step-before","step-after", "basis", "cardinal"]
+
+vis = Rubyvis::Panel.new do |pan|
+  pan.width w 
+  pan.height h 
+  pan.bottom 20 
+  pan.left 20 
+  pan.right 10 
+  pan.top 5 
+
+  interpolations.each_with_index do |inter,i|
+    n=i%2
+    m=(i/2).floor
+    pan.panel do
+      left(n*(p_w+10))
+      top(m*(p_h+10))
+      width p_w
+      height p_h
+      label(:anchor=>'top') do
+        text(inter)
+      end
+      # uses 'a' as reference inside block
+      # to use data method with data variable
+      area do |a| 
+        a.data data
+        a.left {|d| x.scale(d.x)}
+        a.height {|d| y.scale(d.y)}
+        a.bottom 1
+        a.interpolate inter
+      end
+    end
+  end
+end  
+     
+
+vis.render();
+
+
+puts vis.to_svg
diff --git a/examples/1_basic/dot.rb b/examples/1_basic/dot.rb
new file mode 100644
index 0000000..c123d28
--- /dev/null
+++ b/examples/1_basic/dot.rb
@@ -0,0 +1,18 @@
+# = Dot and anchors
+# This example shows how looks differents positions of anchors on dots
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+vis = pv.Panel.new().width(200).height(200);
+
+dot=vis.add(pv.Dot)
+    .data([1,2,3,4,5,6])
+    .bottom(lambda {|d| d*30})
+    .left(lambda { 20+index*40} )
+    .shape_radius(10)
+    %w{top bottom left right center}.each do |dir|
+      dot.anchor(dir).add(pv.Label).text(dir[0,1])
+    end
+vis.render()
+#puts vis.children_inspect
+puts vis.to_svg
diff --git a/examples/1_basic/fixtures/tipsy.gif b/examples/1_basic/fixtures/tipsy.gif
new file mode 100644
index 0000000..74eebae
Binary files /dev/null and b/examples/1_basic/fixtures/tipsy.gif differ
diff --git a/examples/1_basic/grid.rb b/examples/1_basic/grid.rb
new file mode 100644
index 0000000..be3ee1b
--- /dev/null
+++ b/examples/1_basic/grid.rb
@@ -0,0 +1,30 @@
+# = Grid
+# A simple heatmap, using a Bar.fill_style to represent
+# data
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+w = 400
+h = 400
+
+vis = pv.Panel.new()
+  .width(w)
+  .height(h)
+  .bottom(0)
+  .left(0)
+  .right(0)
+  .top(0)
+
+  arrays=10.times.map {|i| 10.times.map {|j| i.quo(10)+j.quo(100)}}
+
+  vis.add(Rubyvis::Layout::Grid).rows(arrays).
+    cell.add(Rubyvis::Bar).
+    fill_style(Rubyvis.ramp("white", "black")).anchor("center").
+    add(Rubyvis::Label).
+    text_style(Rubyvis.ramp("black","white")).
+    text(lambda{|v| "%0.2f" % v })
+
+vis.render();
+
+
+puts vis.to_svg
diff --git a/examples/1_basic/image.rb b/examples/1_basic/image.rb
new file mode 100644
index 0000000..d0cd541
--- /dev/null
+++ b/examples/1_basic/image.rb
@@ -0,0 +1,19 @@
+# = Image
+# This example shows how to include an image 
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+img_url="fixtures/tipsy.gif"
+
+vis = pv.Panel.new().width(200).height(200);
+
+dot=vis.add(pv.Image)
+    .data([1,2,3,4,5,6])
+    .bottom(lambda {|d| d*30})
+    .left(lambda {|d| d*30} )
+    .width(9)
+    .height(9)
+    .url(img_url)
+    
+vis.render()
+puts vis.to_svg
diff --git a/examples/1_basic/line.rb b/examples/1_basic/line.rb
new file mode 100644
index 0000000..a719916
--- /dev/null
+++ b/examples/1_basic/line.rb
@@ -0,0 +1,41 @@
+# = Line Chart
+# This line chart is constructed a Line mark.
+# The second line, inside the first one, is created using an anchor.
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+data = pv.range(0, 10, 0.1).map {|x| 
+  OpenStruct.new({:x=> x, :y=> Math.sin(x) + 2+rand()})
+}
+
+#p data
+w = 400
+h = 200
+x = pv.Scale.linear(data, lambda {|d| d.x}).range(0, w)
+
+
+y = pv.Scale.linear(data, lambda {|d| d.y}).range(0, h);
+
+#/* The root panel. */
+vis = pv.Panel.new()
+  .width(w)
+  .height(h)
+  .bottom(20)
+  .left(20)
+  .right(10)
+  .top(5)
+
+vis.add(pv.Line).
+  data(data).
+  line_width(5).
+  left(lambda {|d| x.scale(d.x)}).
+  bottom(lambda {|d| y.scale(d.y)}).
+  anchor("bottom").add(pv.Line).
+    stroke_style('red').
+    line_width(1)
+     
+
+vis.render();
+
+
+puts vis.to_svg
diff --git a/examples/1_basic/line_interpolation.rb b/examples/1_basic/line_interpolation.rb
new file mode 100644
index 0000000..8207567
--- /dev/null
+++ b/examples/1_basic/line_interpolation.rb
@@ -0,0 +1,64 @@
+# = Line Interpolation
+# This example show the 7 types of interpolation available for lines:
+# * linear
+# * step-before
+# * step-after
+# * polar
+# * polar-reverse
+# * basis
+# * cardinal
+# 
+# See also "Area Interpolation":area_interpolation.html
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+data = pv.range(0, 10, 1).map {|x| 
+  OpenStruct.new({:x=> x, :y=> Math.sin(x) + 2+rand()*0.2})
+}
+
+p_w=200
+p_h=150
+#p data
+w = 20+p_w*2
+h = 20+p_h*4
+
+x = pv.Scale.linear(data, lambda {|d| d.x}).range(0, p_w-30)
+
+
+y = pv.Scale.linear(data, lambda {|d| d.y}).range(0, p_h-20);
+
+interpolations=["linear","step-before","step-after","polar","polar-reverse", "basis", "cardinal"]
+
+#/* The root panel. */
+vis = pv.Panel.new()
+  .width(w)
+  .height(h)
+  .bottom(20)
+  .left(20)
+  .right(10)
+  .top(5)
+
+interpolations.each_with_index do |inter,i|
+  n=i%2
+  m=(i/2).floor
+  panel=vis.add(Rubyvis::Panel).
+  left(n*(p_w+10)).
+  top(m*(p_h+10)).
+  width(p_w).
+  height(p_h)
+  panel.anchor('top').add(Rubyvis::Label).text(inter)
+  panel.add(Rubyvis::Line).data(data).
+  line_width(2).
+  left(lambda {|d| x.scale(d.x)}).
+  bottom(lambda {|d| y.scale(d.y)}).
+  interpolate(inter)
+  
+end
+  
+  
+     
+
+vis.render();
+
+
+puts vis.to_svg
diff --git a/examples/2_medium/censo_agropecuario/censo_agropecuario_chile_data.rb b/examples/2_medium/censo_agropecuario/censo_agropecuario_chile_data.rb
new file mode 100644
index 0000000..8e89c3f
--- /dev/null
+++ b/examples/2_medium/censo_agropecuario/censo_agropecuario_chile_data.rb
@@ -0,0 +1,53 @@
+# encoding: UTF-8
+$censo = [
+{:glosa=>"Alto Bío-Bío", :te=>1, :superficie=>161659.68, :ovinos=>8092, :bovinos=>7736},
+{:glosa=>"Alto Bío-Bío", :te=>2, :superficie=>44214.8, :ovinos=>881, :bovinos=>1327},
+{:glosa=>"Alto Bío-Bío", :te=>3, :superficie=>0, :ovinos=>45, :bovinos=>45},
+{:glosa=>"Alto Bío-Bío", :te=>5, :superficie=>12451.1, :ovinos=>0, :bovinos=>0},
+{:glosa=>"Antuco", :te=>1, :superficie=>67807.4, :ovinos=>1211, :bovinos=>1993},
+{:glosa=>"Antuco", :te=>2, :superficie=>9449.69, :ovinos=>22, :bovinos=>57},
+{:glosa=>"Antuco", :te=>3, :superficie=>0, :ovinos=>0, :bovinos=>0},
+{:glosa=>"Antuco", :te=>5, :superficie=>12883, :ovinos=>0, :bovinos=>0},
+{:glosa=>"Cabrero", :te=>1, :superficie=>33278.04, :ovinos=>1383, :bovinos=>16849},
+{:glosa=>"Cabrero", :te=>2, :superficie=>26802.78, :ovinos=>5, :bovinos=>135},
+{:glosa=>"Cabrero", :te=>3, :superficie=>0, :ovinos=>0, :bovinos=>0},
+{:glosa=>"Laja", :te=>1, :superficie=>16540.64, :ovinos=>1953, :bovinos=>5818},
+{:glosa=>"Laja", :te=>2, :superficie=>12741.56, :ovinos=>0, :bovinos=>52},
+{:glosa=>"Laja", :te=>3, :superficie=>0, :ovinos=>0, :bovinos=>166},
+{:glosa=>"Laja", :te=>4, :superficie=>0.1, :ovinos=>0, :bovinos=>0},
+{:glosa=>"Los Angeles", :te=>1, :superficie=>120432.71, :ovinos=>3640, :bovinos=>87098},
+{:glosa=>"Los Angeles", :te=>2, :superficie=>20205.1, :ovinos=>13, :bovinos=>219},
+{:glosa=>"Los Angeles", :te=>3, :superficie=>0, :ovinos=>0, :bovinos=>9},
+{:glosa=>"Los Angeles", :te=>4, :superficie=>19.4, :ovinos=>0, :bovinos=>0},
+{:glosa=>"Mulchén", :te=>1, :superficie=>87515.1, :ovinos=>5472, :bovinos=>28562},
+{:glosa=>"Mulchén", :te=>2, :superficie=>101300.3, :ovinos=>149, :bovinos=>279},
+{:glosa=>"Mulchén", :te=>3, :superficie=>0, :ovinos=>22, :bovinos=>41},
+{:glosa=>"Mulchén", :te=>4, :superficie=>10, :ovinos=>0, :bovinos=>0},
+{:glosa=>"Nacimiento", :te=>1, :superficie=>25258.2, :ovinos=>2535, :bovinos=>4027},
+{:glosa=>"Nacimiento", :te=>2, :superficie=>47295.23, :ovinos=>155, :bovinos=>266},
+{:glosa=>"Nacimiento", :te=>3, :superficie=>0, :ovinos=>0, :bovinos=>3},
+{:glosa=>"Negrete", :te=>1, :superficie=>10213.42, :ovinos=>564, :bovinos=>7424},
+{:glosa=>"Negrete", :te=>2, :superficie=>1875.2, :ovinos=>0, :bovinos=>0},
+{:glosa=>"Negrete", :te=>3, :superficie=>0, :ovinos=>0, :bovinos=>42},
+{:glosa=>"Quilaco", :te=>1, :superficie=>21624.2, :ovinos=>5078, :bovinos=>5765},
+{:glosa=>"Quilaco", :te=>2, :superficie=>70669.92, :ovinos=>71, :bovinos=>428},
+{:glosa=>"Quilaco", :te=>3, :superficie=>0, :ovinos=>135, :bovinos=>359},
+{:glosa=>"Quilaco", :te=>4, :superficie=>18.1, :ovinos=>0, :bovinos=>0},
+{:glosa=>"Quilleco", :te=>1, :superficie=>46422.6399999999, :ovinos=>8635, :bovinos=>17881},
+{:glosa=>"Quilleco", :te=>2, :superficie=>51873.11, :ovinos=>99, :bovinos=>161},
+{:glosa=>"Quilleco", :te=>4, :superficie=>1089.7, :ovinos=>0, :bovinos=>0},
+{:glosa=>"San Rosendo", :te=>1, :superficie=>3101.07, :ovinos=>52, :bovinos=>314},
+{:glosa=>"San Rosendo", :te=>2, :superficie=>4809.14, :ovinos=>0, :bovinos=>10},
+{:glosa=>"Santa Bárbara", :te=>1, :superficie=>91126.6000000003, :ovinos=>9540, :bovinos=>15316},
+{:glosa=>"Santa Bárbara", :te=>2, :superficie=>30337.87, :ovinos=>273, :bovinos=>678},
+{:glosa=>"Santa Bárbara", :te=>3, :superficie=>0, :ovinos=>12, :bovinos=>37},
+{:glosa=>"Santa Bárbara", :te=>4, :superficie=>45.5, :ovinos=>0, :bovinos=>0},
+{:glosa=>"Tucapel", :te=>1, :superficie=>76164.0399999999, :ovinos=>8941, :bovinos=>5436},
+{:glosa=>"Tucapel", :te=>2, :superficie=>46603.55, :ovinos=>12, :bovinos=>60},
+{:glosa=>"Tucapel", :te=>3, :superficie=>0, :ovinos=>18, :bovinos=>16},
+{:glosa=>"Tucapel", :te=>4, :superficie=>7.8, :ovinos=>0, :bovinos=>0},
+{:glosa=>"Yumbel", :te=>1, :superficie=>31260.98, :ovinos=>1462, :bovinos=>7899},
+{:glosa=>"Yumbel", :te=>2, :superficie=>25284.95, :ovinos=>1, :bovinos=>52},
+{:glosa=>"Yumbel", :te=>3, :superficie=>0, :ovinos=>3, :bovinos=>167},
+{:glosa=>"Yumbel", :te=>4, :superficie=>7.1, :ovinos=>0, :bovinos=>0}
+]
diff --git a/examples/2_medium/censo_agropecuario/census_treemap.rb b/examples/2_medium/censo_agropecuario/census_treemap.rb
new file mode 100644
index 0000000..92ae98c
--- /dev/null
+++ b/examples/2_medium/censo_agropecuario/census_treemap.rb
@@ -0,0 +1,63 @@
+# encoding: UTF-8 
+# = Censo Agropecuario 2007, Chile: Treemap
+# This treemap represents farm explotations on Biobío province, Chile.
+# Colors represent different 'comunas' and bar inside one color
+# represent different types of explotation
+$:.unshift(File.dirname(__FILE__)+"/../../../lib")
+require 'rubyvis'
+load(File.dirname(__FILE__)+"/censo_agropecuario_chile_data.rb")
+
+w = 500
+h = 500
+max_s=30
+
+c_p_c={}
+
+te = {
+ 1=>"Explotación agropecuaria con actividad",
+ 2=>"Explotación forestal", 
+ 3=>"Explotación agropecuaria sin tierra", 
+ 4=>"Explotación agropecuaria temporalmente sin actividad", 
+ 5=>"Parques nacionales y reservas forestales"}
+
+number=Rubyvis::Format.number
+color=Rubyvis::Colors.category20
+
+$censo.each_with_index do |c,i|
+  c_p_c[c[:glosa]]||=Hash.new
+  c_p_c[c[:glosa]][c[:te]]=OpenStruct.new(c)
+end
+
+
+
+nodes = pv.dom(c_p_c).root("censo").nodes
+
+# The root panel.
+vis = pv.Panel.new()
+    .width(w)
+    .height(h)
+    .bottom(20)
+    .left(30)
+    .right(10)
+    .top(5);
+
+treemap = vis.add(Rubyvis::Layout::Treemap).
+  nodes(nodes).mode("squarify").round(true).
+  size(lambda {|d| d.node_value.superficie})
+
+treemap.leaf.add(Rubyvis::Panel).
+  fill_style(lambda{|d| 
+  color.scale(d.node_value.glosa)}).
+  stroke_style("#fff").
+  line_width(1).
+  antialias(false).
+  title(lambda {|d| d.parent_node ? d.node_value.glosa+"-#{te[d.node_value.te]}" : ""})
+
+treemap.node_label.add(Rubyvis::Label).
+  text_style(lambda {|d| pv.rgb(0, 0, 0, 1)}).
+  visible(lambda {|d| d.node_value and d.node_value.superficie>200}).
+  text(lambda {|d| number.format(d.node_value.superficie.to_i)})
+    
+
+vis.render()
+puts vis.to_svg
diff --git a/examples/2_medium/censo_agropecuario/create_data.rb b/examples/2_medium/censo_agropecuario/create_data.rb
new file mode 100644
index 0000000..8aaf7cf
--- /dev/null
+++ b/examples/2_medium/censo_agropecuario/create_data.rb
@@ -0,0 +1,10 @@
+require 'statsample'
+a=Statsample::CSV.read('resultset.csv')
+File.open("censo_agropecuario_chile_data.rb","w") do |fp|
+  fp.puts "# encoding: UTF-8"
+  fp.puts "$censo = ["
+  a.each do |row|
+    fp.puts row.inject({}) {|ac,v| ac[v[0].to_sym]=v[1];ac}.inspect+","
+  end
+  fp.puts "]"
+end
diff --git a/examples/2_medium/censo_agropecuario/resultset.csv b/examples/2_medium/censo_agropecuario/resultset.csv
new file mode 100644
index 0000000..e86993b
--- /dev/null
+++ b/examples/2_medium/censo_agropecuario/resultset.csv
@@ -0,0 +1,51 @@
+"glosa","te","superficie","ovinos","bovinos"
+"Alto Bío-Bío",1,161659.68,8092,7736
+"Alto Bío-Bío",2,44214.8,881,1327
+"Alto Bío-Bío",3,0,45,45
+"Alto Bío-Bío",5,12451.1,0,0
+"Antuco",1,67807.4,1211,1993
+"Antuco",2,9449.69,22,57
+"Antuco",3,0,0,0
+"Antuco",5,12883,0,0
+"Cabrero",1,33278.04,1383,16849
+"Cabrero",2,26802.78,5,135
+"Cabrero",3,0,0,0
+"Laja",1,16540.64,1953,5818
+"Laja",2,12741.56,0,52
+"Laja",3,0,0,166
+"Laja",4,0.1,0,0
+"Los Angeles",1,120432.71,3640,87098
+"Los Angeles",2,20205.1,13,219
+"Los Angeles",3,0,0,9
+"Los Angeles",4,19.4,0,0
+"Mulchén",1,87515.1,5472,28562
+"Mulchén",2,101300.3,149,279
+"Mulchén",3,0,22,41
+"Mulchén",4,10,0,0
+"Nacimiento",1,25258.2,2535,4027
+"Nacimiento",2,47295.23,155,266
+"Nacimiento",3,0,0,3
+"Negrete",1,10213.42,564,7424
+"Negrete",2,1875.2,0,0
+"Negrete",3,0,0,42
+"Quilaco",1,21624.2,5078,5765
+"Quilaco",2,70669.92,71,428
+"Quilaco",3,0,135,359
+"Quilaco",4,18.1,0,0
+"Quilleco",1,46422.6399999999,8635,17881
+"Quilleco",2,51873.11,99,161
+"Quilleco",4,1089.7,0,0
+"San Rosendo",1,3101.07,52,314
+"San Rosendo",2,4809.14,0,10
+"Santa Bárbara",1,91126.6000000003,9540,15316
+"Santa Bárbara",2,30337.87,273,678
+"Santa Bárbara",3,0,12,37
+"Santa Bárbara",4,45.5,0,0
+"Tucapel",1,76164.0399999999,8941,5436
+"Tucapel",2,46603.55,12,60
+"Tucapel",3,0,18,16
+"Tucapel",4,7.8,0,0
+"Yumbel",1,31260.98,1462,7899
+"Yumbel",2,25284.95,1,52
+"Yumbel",3,0,3,167
+"Yumbel",4,7.1,0,0
diff --git a/examples/2_medium/horizon.rb b/examples/2_medium/horizon.rb
new file mode 100644
index 0000000..b18f1de
--- /dev/null
+++ b/examples/2_medium/horizon.rb
@@ -0,0 +1,58 @@
+# = Horizon
+# Horizon graphs increase data density while preserving resolution. 
+# While horizon graphs may require learning, they have been found to be more effective than standard line and area plots when chart sizes are small. For more, see "Sizing the Horizon: The Effects of Chart Size and Layering on the Graphical Perception of Time Series Visualizations" by Heer et al., CHI 2009.
+# This example shows +offset+ and +mirror+ modes for the quadratic equation x^2-10
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+data = Rubyvis.range(-5, 5, 0.1).map {|x|
+  OpenStruct.new({:x=> x, :y=>  x**2-10})
+}
+
+
+
+#p data
+w = 400
+h = 100
+x = pv.Scale.linear(data, lambda {|d| d.x}).range(0, w)
+y = pv.Scale.linear(data, lambda {|d| d.y}).range(-50, h*2);
+
+#/* The root panel. */
+vis = pv.Panel.new()
+  .width(w)
+  .height(h*2+20)
+  .bottom(20)
+  .left(20)
+  .right(10)
+  .top(5)
+
+types=["offset","mirror"]
+
+
+pan=vis.add(Rubyvis::Panel).
+data(types).
+height(80).
+top(lambda { index*110+30})
+pan.add(Rubyvis::Rule).
+  data(x.ticks).
+  left(x).
+  anchor("bottom").
+  add(Rubyvis::Label).
+  text(x.tick_format)
+  
+  
+pan.add(Rubyvis::Layout::Horizon)
+         .bands(3)
+         .mode(lambda {|d| d})         
+       .band.add(Rubyvis::Area)
+         .data(data)
+         .left(lambda {|d| x[d.x]})
+         .height(lambda {|d| y[d.y]})
+     
+pan.anchor("top").add(Rubyvis::Label)
+.top(-15)
+
+vis.render();
+
+
+puts vis.to_svg
diff --git a/examples/2_medium/nested_grid.rb b/examples/2_medium/nested_grid.rb
new file mode 100644
index 0000000..23a1cc1
--- /dev/null
+++ b/examples/2_medium/nested_grid.rb
@@ -0,0 +1,52 @@
+# = Nested grid
+# Two level nested grid.  The first is created at random with n rows and m columns The second level is a 9x9 grid inside the cell of first level
+# You can obtain the same result using a grid layout
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+
+w = 600
+h = 600
+cs=pv.Colors.category20()
+rows=2.0+rand(3)
+cols=2.0+rand(3)
+row_h=h/rows
+col_w=w/cols
+cel_h=row_h/3.0
+cel_w=col_w/3.0
+
+letters=%w{a b c d e f g h i j k}
+
+    
+vis = pv.Panel.new()
+    .width(w)
+    .height(h);
+    
+p1=vis.add(pv.Panel).data(letters[0,rows]).
+  top(lambda {index*(row_h)}).
+  height(row_h)
+
+p2=p1.add(pv.Panel).data(letters[0,cols]).
+  width(col_w).
+  left(lambda {index*(col_w)})
+
+p2.anchor("center").add(pv.Label).
+  text(lambda {|d,a,b| return "#{b}-#{a}"}).
+  font("bold large Arial")
+
+
+p2.add(pv.Bar).data([1,2,3,4,5,6,7,8,9]).
+  width(-3+cel_w).
+  height(-3+cel_h).
+  visible(lambda {|d| d!=5}).
+  fillStyle(lambda {|d| cs.scale(d)}).
+  top(lambda { (index / 3.0).floor*cel_h}).
+  left(lambda { (index % 3)*cel_w}).
+  anchor('center').
+    add(pv.Label).
+      visible(lambda {|a,b,c| a!=5}).
+      text(lambda {|a,b,c| "#{c}-#{b}-#{a}"})
+
+vis.render();
+
+puts vis.to_svg
diff --git a/examples/3_pv_conventional/area.rb b/examples/3_pv_conventional/area.rb
new file mode 100644
index 0000000..919a66b
--- /dev/null
+++ b/examples/3_pv_conventional/area.rb
@@ -0,0 +1,67 @@
+# = Area Charts
+# This simple area chart is constructed using an area mark, with an added line for emphasis on the top edge. Next, rules and labels are added for reference values.
+# Although this example is basic, it provides a good starting point for adding more complex features. For instance, multiple series of data can be added to produce a stacked area chart. 
+# * "Protovis version":http://vis.stanford.edu/protovis/ex/area.html
+# * Syntax: RBP
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+data = pv.range(0, 10, 0.1).map {|x| 
+  OpenStruct.new({:x=> x, :y=> Math.sin(x) + 2+ rand()})
+}
+
+
+w = 400
+h = 200
+x = pv.Scale.linear(data, lambda {|d| d.x}).range(0, w)
+
+
+y = pv.Scale.linear(0, 4).range(0, h);
+
+#The root panel
+vis = pv.Panel.new() do
+  width w
+  height h
+  bottom 20
+  left 20
+  right 10
+  top 5
+
+# Y-axis and ticks
+  rule do
+    data y.ticks(5)
+    bottom(y)
+    stroke_style {|d| d!=0 ? "#eee" : "#000"}
+    label(:anchor=>"left") {
+      text y.tick_format
+    }
+  end
+  
+# X-axis and ticks.
+  rule do
+    data x.ticks()
+    visible {|d| d!=0}
+    left(x)
+    bottom(-5)
+    height(5)
+    label(:anchor=>'bottom') {
+      text(x.tick_format)
+    }
+  end
+
+#/* The area with top line. */
+  area do |a|
+    a.data data
+    a.bottom(1)
+    a.left {|d| x.scale(d.x)}
+    a.height {|d| y.scale(d.y)}
+    a.fill_style("rgb(121,173,210)")
+    a.line(:anchor=>'top') {
+      line_width(3)
+    }
+  end
+end
+vis.render();
+
+
+puts vis.to_svg
diff --git a/examples/3_pv_conventional/bar_column_chart.rb b/examples/3_pv_conventional/bar_column_chart.rb
new file mode 100644
index 0000000..54d71e7
--- /dev/null
+++ b/examples/3_pv_conventional/bar_column_chart.rb
@@ -0,0 +1,59 @@
+# = Bar & Column Charts
+# This simple bar chart is constructed using a bar mark. A linear scale is used to compute the width of the bar, while an ordinal scale sets the top position and height for the categorical dimension. Next, rules and labels are added for reference values.
+# Bars can be used in a variety of ways. For instance, they can be stacked or grouped to show multiple data series, or arranged as vertical columns rather than bars. 
+
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+data = pv.range(10).map {|d| rand + 0.1 }
+
+
+
+#/* Sizing and scales. *
+w = 400
+h = 250
+x = pv.Scale.linear(0, 1.1).range(0, w)
+y = pv.Scale.ordinal(pv.range(10)).split_banded(0, h, 4/5.0)
+
+#/* The root panel. */
+vis = pv.Panel.new()
+    .width(w)
+    .height(h)
+    .bottom(20)
+    .left(20)
+    .right(10)
+    .top(5);
+
+#/* The bars. */
+bar = vis.add(pv.Bar)
+    .data(data)
+    .top(lambda { y.scale(self.index)})
+    .height(y.range_band)
+    .left(0)
+    .width(x)
+
+#/* The value label. */
+bar.anchor("right").add(pv.Label)
+    .text_style("white")
+    .text(lambda {|d| "%0.1f" % d})
+
+#/* The variable label. */
+bar.anchor("left").add(pv.Label)
+    .text_margin(5)
+    .text_align("right")
+    .text(lambda { "ABCDEFGHIJK"[self.index,1]});
+ 
+#/* X-axis ticks. */
+vis.add(pv.Rule)
+    .data(x.ticks(5))
+    .left(x)
+    .stroke_style(lambda {|d|  d!=0 ? "rgba(255,255,255,.3)" : "#000"})
+  .add(pv.Rule)
+    .bottom(0)
+    .height(5)
+    .stroke_style("#000")
+  .anchor("bottom").add(pv.Label)
+  .text(x.tick_format);
+
+vis.render();
+puts vis.to_svg
diff --git a/examples/3_pv_conventional/grouped_charts.rb b/examples/3_pv_conventional/grouped_charts.rb
new file mode 100644
index 0000000..3fd7471
--- /dev/null
+++ b/examples/3_pv_conventional/grouped_charts.rb
@@ -0,0 +1,70 @@
+# = Grouped charts
+# In this multi-series bar chart, we group bars together rather than stack them. A grouped chart allows accurate comparison of individual values thanks to an aligned baseline: a position, rather than length, judgment is used.
+# An ordinal scale positions the groups vertically; the bars are then replicated inside a panel, a technique that is also used for small multiples. 
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+n = 3
+m = 4
+data = pv.range(n).map {
+    pv.range(m).map {
+        rand() + 0.1;
+      }
+}
+
+
+w = 400
+h = 250
+x = pv.Scale.linear(0, 1.1).range(0, w)
+y = pv.Scale.ordinal(pv.range(n)).split_banded(0, h, 4/5.0);
+
+#/* The root panel. */
+vis = pv.Panel.new()
+    .width(w)
+    .height(h)
+    .bottom(20)
+    .left(20)
+    .right(10)
+    .top(5);
+
+#/* The bars. */
+
+colors=pv.Colors.category20()
+
+bar = vis.add(pv.Panel)
+    .data(data)
+    .top(lambda {y.scale(self.index)})
+    .height(y.range_band)
+  .add(pv.Bar)
+    .data(lambda {|d| d})
+    .top(lambda {self.index * y.range_band / m.to_f})
+    .height(y.range_band / m.to_f)
+    .left(0)
+    .width(x)
+    .fillStyle(lambda { colors.scale(self.index)})
+
+#/* The value label. */
+bar.anchor("right").add(pv.Label)
+    .textStyle("white")
+    .text(lambda {|d| "%0.1f" % d});
+
+#/* The variable label. */
+bar.parent.anchor("left").add(pv.Label)
+    .textAlign("right")
+    .textMargin(5)
+    .text(lambda {"ABCDEFGHIJK"[self.parent.index,1]});
+
+#/* X-axis ticks. */
+vis.add(pv.Rule)
+    .data(x.ticks(5))
+    .left(x)
+    .strokeStyle(lambda {|d| d!=0 ? "rgba(255,255,255,.3)" : "#000"})
+  .add(pv.Rule)
+    .bottom(0)
+    .height(5)
+    .strokeStyle("#000")
+  .anchor("bottom").add(pv.Label)
+    .text(x.tick_format);
+
+vis.render();
+puts vis.to_svg
diff --git a/examples/3_pv_conventional/line_and_step.rb b/examples/3_pv_conventional/line_and_step.rb
new file mode 100644
index 0000000..1ab8958
--- /dev/null
+++ b/examples/3_pv_conventional/line_and_step.rb
@@ -0,0 +1,65 @@
+# = Line and Step Chart
+# Line charts are often used to visualize time series data, encoding the value of a variable over time using position. Typically, linear interpolation is used between samples. However, in some cases, the data does not vary smoothly, but instead changes in response to discrete events.
+# Using the interpolate property, it is easy to change this behavior for lines and areas. Rubyvis also supports various nonlinear interpolation methods, including cardinal spline, Catmull-Rom spline, B-spline, and monotone cubic.
+
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+data = pv.range(0, 10, 0.2).map {|x| 
+  OpenStruct.new({:x=> x, :y=> Math.sin(x) + rand() + 1.5})
+}
+
+
+vis = pv.Panel.new().width(200).height(200);
+
+
+w = 400
+h = 200
+x = pv.Scale.linear(data, lambda {|d| d.x}).range(0, w)
+  
+y = pv.Scale.linear(0, 4).range(0, h);
+
+#/* The root panel. */
+vis = pv.Panel.new()
+    .width(w)
+    .height(h)
+    .bottom(20)
+    .left(20)
+    .right(10)
+    .top(5);
+
+#/* X-axis ticks. */
+vis.add(pv.Rule)
+    .data(x.ticks())
+    .visible(lambda {|d|  d > 0})
+    .left(x)
+    .strokeStyle("#eee")
+  .add(pv.Rule)
+    .bottom(-5)
+    .height(5)
+    .strokeStyle("#000")
+  .anchor("bottom").add(pv.Label)
+  .text(x.tick_format)
+
+#/* Y-axis ticks. */
+vis.add(pv.Rule)
+    .data(y.ticks(5))
+    .bottom(y)
+    .strokeStyle(lambda {|d| d!=0 ? "#eee" : "#000"})
+  .anchor("left").add(pv.Label)
+  .text(y.tick_format);
+
+#/* The line. */
+vis.add(pv.Line)
+    .data(data)
+    .interpolate("step-after")
+    .left(lambda {|d| x.scale(d.x)})
+    .bottom(lambda {|d| y.scale(d.y)})
+    .lineWidth(3);
+
+vis.render();
+
+
+    
+
+puts vis.to_svg
diff --git a/examples/3_pv_conventional/pie_and_donut.rb b/examples/3_pv_conventional/pie_and_donut.rb
new file mode 100644
index 0000000..379e5b4
--- /dev/null
+++ b/examples/3_pv_conventional/pie_and_donut.rb
@@ -0,0 +1,38 @@
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+# Sizing and scales. */
+
+data = pv.range(10).map {rand()}
+
+
+w = 400
+h = 400
+
+r = w / 2.0
+
+a = pv.Scale.linear(0, pv.sum(data)).range(0, 2 * Math::PI)
+
+#/* The root panel. */
+vis = pv.Panel.new()
+    .width(w)
+    .height(h);
+#/* The wedge, with centered label. */
+
+vis.add(pv.Wedge)
+    .data(data.sort(&pv.reverse_order))
+    .bottom(w / 2.0)
+    .left(w / 2.0)
+    .innerRadius(r - 40)
+    .outerRadius(r)
+    .angle(a)
+    .event("mouseover", lambda {self.inner_radius(0)})
+    .event("mouseout", lambda{ self.inner_radius(r - 40)})
+  .anchor("center").add(pv.Label)
+  .visible(lambda {|d|  d > 0.15})
+    .textAngle(0)
+    .text(lambda {|d| "%0.2f" %  d});
+
+vis.render();
+
+puts vis.to_svg
diff --git a/examples/3_pv_conventional/scatterplot.rb b/examples/3_pv_conventional/scatterplot.rb
new file mode 100644
index 0000000..78e328a
--- /dev/null
+++ b/examples/3_pv_conventional/scatterplot.rb
@@ -0,0 +1,57 @@
+# = Scatterplot
+# Scatterplots can facilitate visual analysis along multiple dimensions, though care should be taken to avoid interference. In this example, we encode three dimensions: two are encoded using position, while the third is redundantly encoded as both area and color. 
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+data = pv.range(100).map {|x| 
+  OpenStruct.new({x: x, y: rand(), z: 10**(2*rand)})
+}
+
+
+w = 400
+h = 400
+
+x = pv.Scale.linear(0, 99).range(0, w)
+y = pv.Scale.linear(0, 1).range(0, h)
+
+c = pv.Scale.log(1, 100).range("orange", "brown")
+
+# The root panel.
+vis = pv.Panel.new()
+    .width(w)
+    .height(h)
+    .bottom(20)
+    .left(20)
+    .right(10)
+    .top(5);
+
+# Y-axis and ticks. 
+vis.add(pv.Rule)
+    .data(y.ticks())
+    .bottom(y)
+    .strokeStyle(lambda {|d| d!=0 ? "#eee" : "#000"})
+  .anchor("left").add(pv.Label)
+  .visible(lambda {|d|  d > 0 and d < 1})
+  .text(y.tick_format)
+
+# X-axis and ticks. 
+vis.add(pv.Rule)
+    .data(x.ticks())
+    .left(x)
+    .stroke_style(lambda {|d| d!=0 ? "#eee" : "#000"})
+  .anchor("bottom").add(pv.Label)
+  .visible(lambda {|d|  d > 0 and d < 100})
+  .text(x.tick_format);
+
+#/* The dot plot! */
+vis.add(pv.Panel)
+    .data(data)
+  .add(pv.Dot)
+  .left(lambda {|d| x.scale(d.x)})
+  .bottom(lambda {|d| y.scale(d.y)})
+  .stroke_style(lambda {|d| c.scale(d.z)})
+  .fill_style(lambda {|d| c.scale(d.z).alpha(0.2)})
+  .shape_size(lambda {|d| d.z})
+  .title(lambda {|d| "%0.1f" % d.z})
+
+vis.render()
+puts vis.to_svg
diff --git a/examples/3_pv_conventional/stacked_charts.rb b/examples/3_pv_conventional/stacked_charts.rb
new file mode 100644
index 0000000..74ca407
--- /dev/null
+++ b/examples/3_pv_conventional/stacked_charts.rb
@@ -0,0 +1,50 @@
+# = Stacked Area
+# This example uses the Stack layout to stack areas one over another.
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+data = pv.range(4).map {|i|
+  pv.range(0, 10, 0.1).map {|x|
+    OpenStruct.new({:x=> x, :y=> Math.sin(x) + rand() * 0.5 + 2})
+  }
+}
+
+w = 400
+h = 200
+
+x = pv.Scale.linear(0, 9.9).range(0, w)
+y = pv.Scale.linear(0, 14).range(0, h)
+
+#/* The root panel. */
+vis = pv.Panel.new()
+    .width(w)
+    .height(h)
+    .bottom(20)
+    .left(20)
+    .right(10)
+    .top(5)
+#/* X-axis and ticks. */
+vis.add(pv.Rule)
+    .data(x.ticks())
+    .visible(lambda {|d| d!=0})
+    .left(x)
+    .bottom(-5)
+    .height(5)
+  .anchor("bottom").add(pv.Label)
+  .text(x.tick_format)
+#/* Y-axis and ticks. */
+vis.add(pv.Rule)
+    .data(y.ticks(3))
+    .bottom(y)
+    .strokeStyle(lambda {|d|  d!=0 ? "rgba(128,128,128,.2)" : "#000"})
+  .anchor("left").add(pv.Label)
+  .text(y.tick_format)
+#/* The stack layout. */
+vis.add(pv.Layout.Stack)
+    .layers(data)
+    .x(lambda {|d| x.scale(d.x)})
+    .y(lambda {|d| y.scale(d.y)})
+  .layer.add(pv.Area)
+
+vis.render();
+puts vis.to_svg
diff --git a/examples/4_pv_custom/antibiotics/antibiotics_data.rb b/examples/4_pv_custom/antibiotics/antibiotics_data.rb
new file mode 100644
index 0000000..55eb537
--- /dev/null
+++ b/examples/4_pv_custom/antibiotics/antibiotics_data.rb
@@ -0,0 +1,20 @@
+$antibiotics = ["penicillin", "streptomycin", "neomycin"];
+
+$bacteria = [
+  {name: "Mycobacterium tuberculosis", penicillin: 800, streptomycin: 5, neomycin: 2, gram: "negative"},
+  {name: "Salmonella schottmuelleri", penicillin: 10, streptomycin: 0.8, neomycin: 0.09, gram: "negative"},
+  {name: "Proteus vulgaris", penicillin: 3, streptomycin: 0.1, neomycin: 0.1, gram: "negative"},
+  {name: "Klebsiella pneumoniae", penicillin: 850, streptomycin: 1.2, neomycin: 1, gram: "negative"},
+  {name: "Brucella abortus", penicillin: 1, streptomycin: 2, neomycin: 0.02, gram: "negative"},
+  {name: "Pseudomonas aeruginosa", penicillin: 850, streptomycin: 2, neomycin: 0.4, gram: "negative"},
+  {name: "Escherichia coli", penicillin: 100, streptomycin: 0.4, neomycin: 0.1, gram: "negative"},
+  {name: "Salmonella (Eberthella) typhosa", penicillin: 1, streptomycin: 0.4, neomycin: 0.008, gram: "negative"},
+  {name: "Aerobacter aerogenes", penicillin: 870, streptomycin: 1, neomycin: 1.6, gram: "negative"},
+  {name: "Brucella antracis", penicillin: 0.001, streptomycin: 0.01, neomycin: 0.007, gram: "positive"},
+  {name: "Streptococcus fecalis", penicillin: 1, streptomycin: 1, neomycin: 0.1, gram: "positive"},
+  {name: "Staphylococcus aureus", penicillin: 0.03, streptomycin: 0.03, neomycin: 0.001, gram: "positive"},
+  {name: "Staphylococcus albus", penicillin: 0.007, streptomycin: 0.1, neomycin: 0.001, gram: "positive"},
+  {name: "Streptococcus hemolyticus", penicillin: 0.001, streptomycin: 14, neomycin: 10, gram: "positive"},
+  {name: "Streptococcus viridans", penicillin: 0.005, streptomycin: 10, neomycin: 40, gram: "positive"},
+  {name: "Diplococcus pneumoniae", penicillin: 0.005, streptomycin: 11, neomycin: 10, gram: "positive"}
+];
diff --git a/examples/4_pv_custom/antibiotics/antibiotics_scatter.rb b/examples/4_pv_custom/antibiotics/antibiotics_scatter.rb
new file mode 100644
index 0000000..6825774
--- /dev/null
+++ b/examples/4_pv_custom/antibiotics/antibiotics_scatter.rb
@@ -0,0 +1,107 @@
+# = Antibiotic Effectiveness : Scatterplot
+# After World War II, antibiotics earned the moniker “wonder drugs” for quickly treating previously-incurable diseases. Data was gathered to determine which drug worked best for each bacterial infection. Comparing drug performance was an enormous aid for practitioners and scientists alike. In the fall of 1951, Will Burtin published this graph showing the effectiveness of three popular antibiotics on 16 different bacteria, measured in terms of minimum inhibitory concentration.
+# Recreating this display revealed some minor errors in the original: a missing grid line at 0.01 μg/ml, and an exaggeration of some values for penicillin. 
+$:.unshift(File.dirname(__FILE__)+"/../../../lib")
+require 'rubyvis'
+load(File.dirname(__FILE__)+"/antibiotics_data.rb")
+
+s = 180
+_p = 20
+z = pv.Scale.log(0.001, 1000).range(0, s)
+color = pv.colors("darkred", "darkblue")
+ticks = pv.range(-2, 3).map {|e| (10**e).to_f}
+
+#/* Root panel. */
+vis = Rubyvis::Panel.new
+    .height(s * $antibiotics.size+ _p * ($antibiotics.size- 1))
+    .width(lambda {self.height()})
+    .top(14.5)
+    .left(14.5)
+    .bottom(44)
+    .right(14);
+
+#/* Cell for each antibiotic pair. */
+cell = vis.add(pv.Panel)
+    .data($antibiotics)
+    .width(s)
+    .left(lambda {(s + _p) * self.index})
+  .add(pv.Panel)
+    .data($antibiotics)
+    .height(s)
+    .top(lambda{(s + _p) * self.index})
+
+#/* Label. */
+cell.anchor("center").add(pv.Label)
+.visible(lambda {|d,y, x| return  x == y})
+    .font("bold 14px sans-serif")
+    .text(lambda {|d, y, x| x});
+
+#/* Dot plot and frame. */
+plot = cell.add(pv.Panel)
+    .data(lambda {|y, x| [x]})
+    .visible(lambda {|x, y| x != y})
+    .stroke_style("#aaa");
+
+#/* Ticks. */
+tick = pv.Rule.new()
+    .visible(lambda {|d, x, y| x != y})
+    .data(ticks)
+    .stroke_style("#ddd");
+
+#/* X-axis ticks. */
+xtick = plot.add(pv.Rule)
+    .mark_extend(tick)
+    .left(z);
+
+#/* Bottom and top labels. */
+xtick.anchor("bottom").add(pv.Label)
+    .visible(lambda {cell.index == $antibiotics.size- 1});
+xtick.anchor("top").add(pv.Label)
+    .visible(lambda {cell.index == 0});
+
+#/* Y-axis ticks. */
+ytick = plot.add(pv.Rule)
+    .mark_extend(tick)
+    .bottom(z);
+
+#/* Bottom and top labels. */
+ytick.anchor("right").add(pv.Label)
+    .visible(lambda {cell.parent.index == $antibiotics.size- 1})
+    .text_angle(Math::PI / 2.0)
+    .text_baseline("bottom")
+    .text_align("center");
+ytick.anchor("left").add(pv.Label)
+    .visible(lambda {cell.parent.index == 0})
+    .text_angle(-Math::PI / 2.0)
+    .text_baseline("bottom")
+    .text_align("center");
+
+#/* Dot plot. */
+dot = plot.add(pv.Dot).
+  data($bacteria).
+  stroke_style(lambda { |d|
+    color.scale(d[:gram])
+  }).
+  fill_style(lambda {|d|
+    color.scale(d[:gram]).alpha(0.2)
+  }).
+  left(lambda {|d, x, y|
+    z.scale(d[x.to_sym])
+  }).
+  bottom(lambda {|d, x, y|
+    z.scale(d[y.to_sym])
+  }).
+  title(lambda {|d| d[:name]})
+
+#/* Legend. */
+vis.add(pv.Dot)
+    .mark_extend(dot)
+    .data([{gram:"positive"}, {gram:"negative"}])
+    .bottom(-30)
+    .left(lambda { index * 100})
+    .title(nil)
+  .anchor("right").add(pv.Label)
+    .text(lambda {|d| "Gram-" + d[:gram]});
+
+vis.render();
+puts vis.to_svg
diff --git a/examples/4_pv_custom/antibiotics/antibiotics_wedge.rb b/examples/4_pv_custom/antibiotics/antibiotics_wedge.rb
new file mode 100644
index 0000000..e20b61c
--- /dev/null
+++ b/examples/4_pv_custom/antibiotics/antibiotics_wedge.rb
@@ -0,0 +1,142 @@
+# = Antibiotic Effectiveness : Pie chart
+# After World War II, antibiotics earned the moniker “wonder drugs” for quickly treating previously-incurable diseases. Data was gathered to determine which drug worked best for each bacterial infection. Comparing drug performance was an enormous aid for practitioners and scientists alike. In the fall of 1951, Will Burtin published this graph showing the effectiveness of three popular antibiotics on 16 different bacteria, measured in terms of minimum inhibitory concentration.
+# Recreating this display revealed some minor errors in the original: a missing grid line at 0.01 μg/ml, and an exaggeration of some values for penicillin.
+$:.unshift(File.dirname(__FILE__)+"/../../../lib")
+require 'rubyvis'
+load(File.dirname(__FILE__)+"/antibiotics_data.rb")
+
+width = 700
+height = 700
+inner_radius = 90
+outer_radius = 300 - 10
+
+drug_color = {
+  :penicillin=> "rgb(10, 50, 100)",
+  :streptomycin=> "rgb(200, 70, 50)",
+  :neomycin=> "black"
+}
+gram_color = {
+  :positive=> "rgba(174, 174, 184, .8)",
+  :negative=> "rgba(230, 130, 110, .8)"
+}
+
+# Burtin's radius encoding is, as far as I can tell, sqrt(log(mic)).
+min = Math.sqrt(Math.log(0.001 * 1e4))
+max = Math.sqrt(Math.log(1000 * 1e4))
+a = (outer_radius - inner_radius) / (min - max.to_f)
+b = inner_radius - a * max
+
+radius = lambda {|mic| a * Math.sqrt(Math.log(mic * 1e4)) + b}
+
+# The pie is split into equal sections for each bacteria, with a blank
+# section at the top for the grid labels. Each wedge is further
+# subdivided to make room for the three antibiotics, equispaced.
+
+big_angle = 2.0 * Math::PI / ($bacteria.length + 1.0)
+small_angle = big_angle / 7.0
+#/* The root panel. */
+vis = Rubyvis::Panel.new.
+  width(width).
+  height(height).
+  bottom(100);
+
+
+
+# Background wedges to indicate gram staining color.
+bg = vis.add(Rubyvis::Wedge).
+  data($bacteria). # assumes Burtin's order
+  left(lambda {|i| width / 2.0}).
+  top(height / 2.0).
+  inner_radius(inner_radius).
+  outer_radius(outer_radius).
+  angle(big_angle).
+  start_angle(lambda {|d| 
+  index * big_angle + big_angle / 2.0 - Math::PI / 2.0
+  }).
+  fill_style(lambda {|d|
+  Rubyvis.color(gram_color[d[:gram].to_sym])
+  })
+
+# Antibiotics. 
+
+bg.add(Rubyvis::Wedge).
+  angle(small_angle).
+  start_angle(lambda {|d| 
+    bg.start_angle() + small_angle
+  }).
+  outer_radius(lambda {|d| 
+  radius.call(d[:penicillin])
+  }).
+  fill_style(drug_color[:penicillin]).
+    add(Rubyvis::Wedge).
+    start_angle(lambda {|d| 
+    proto.start_angle() + 2 * small_angle}).
+    outer_radius(lambda {|d| 
+      radius.call(d[:streptomycin])
+    }).
+    fill_style(drug_color[:streptomycin]).
+    add(Rubyvis::Wedge).
+    outer_radius(lambda {|d|
+      radius.call(d[:neomycin])
+    }).
+    fill_style(drug_color[:neomycin])
+
+# Circular grid lines. 
+
+bg.add(Rubyvis::Dot)
+    .data(Rubyvis.range(-3, 4))
+    .fill_style(nil)
+    .stroke_style("#eee")
+    .line_width(1)
+    .shape_size(lambda {|i| 
+      radius.call(10**i)** 2
+    }).
+  anchor("top").add(Rubyvis::Label).
+    visible(lambda {|i| i < 3}).
+    text_baseline("middle").
+    text(lambda {|i| 
+      i<0 ? (10** i).to_f : (10**i).to_i
+    })
+
+# Radial grid lines. 
+
+bg.add(Rubyvis::Wedge)
+.data(Rubyvis.range($bacteria.size + 1))
+    .inner_radius(inner_radius - 10)
+    .outer_radius(outer_radius + 10)
+    .fill_style(nil)
+    .stroke_style("black")
+    .angle(0)
+
+# Labels. 
+bg.anchor("outer").add(Rubyvis::Label)
+    .text_align("center")
+    .text(lambda {|d| d[:name]})
+
+# Antibiotic legend. 
+vis.add(Rubyvis::Bar)
+    .data(Rubyvis.keys(drug_color))
+    .right(width / 2 + 3)
+    .top(lambda { height / 2.0 - 28 + self.index * 18})
+    .fill_style(lambda {|d| drug_color[d]})
+    .width(36)
+    .height(12)
+  .anchor("right").add(Rubyvis::Label)
+    .textMargin(6)
+    .textAlign("left");
+
+# Gram-stain legend.
+vis.add(Rubyvis::Dot).
+  data([:positive, :negative]).
+  left(width / 2.0 - 20).
+  bottom(lambda { -60 + index * 18}).
+  fill_style(lambda {|d| gram_color[d]}).
+  stroke_style(nil).
+  shape_size(30).
+  anchor("right").add(Rubyvis::Label).
+    text_margin(6).
+    text_align("left").
+    text(lambda {|d| "Gram-#{d}"})
+
+vis.render
+puts vis.to_svg
diff --git a/examples/4_pv_custom/barley/barley.rb b/examples/4_pv_custom/barley/barley.rb
new file mode 100644
index 0000000..5b0a01b
--- /dev/null
+++ b/examples/4_pv_custom/barley/barley.rb
@@ -0,0 +1,97 @@
+# = Becker’s Barley
+# The "Trellis display":http://www.jstor.org/stable/1390777 by Becker et al. helped establish small multiples as a “powerful mechanism for understanding interactions in studies of how a response depends on explanatory variables”. Here we reproduce a trellis of Barley yields from the 1930s, complete with main-effects ordering to facilitate comparison. These examples demonstrate Protovis’ support for data transformation via the nest operator.
+# Notice anything unusual about one of the sites? This anomaly led Becker et al. to suspect a major error with the data that went undetected for six decades. 
+
+$:.unshift(File.dirname(__FILE__)+"/../../../lib")
+require 'rubyvis'
+load(File.dirname(__FILE__)+"/barley_data.rb")
+# Nest yields data by site then year. */
+
+# Compute yield medians by site and by variety. */
+median=lambda {|data| 
+       pv.median(data, lambda {|d| d[:yield]}) 
+       }
+
+site = pv.nest($barley).
+       key(lambda {|d| d[:site]}).
+       rollup(median)
+
+variety = pv.nest($barley).key(lambda {|d| d[:variety]}).rollup(median);
+
+
+barley = pv.nest($barley)
+    .key(lambda {|d| d[:site]})
+    .sort_keys(lambda {|a, b| site[b] - site[a]})
+    .key(lambda {|d| d[:year]})
+    .sort_values(lambda {|a, b| variety[b[:variety]] - variety[a[:variety]]})
+    .entries()
+
+# Sizing and scales. */
+w = 332
+h = 132
+x = pv.Scale.linear(10, 90).range(0, w)
+c = pv.Colors.category10()
+
+# The root panel. */
+vis = Rubyvis::Panel.new
+    .width(w)
+    .height(h * pv.keys(site).size)
+    .top(15.5)
+    .left(0.5)
+    .right(0.5)
+    .bottom(25);
+
+# A panel per site-year. */
+cell = vis.add(pv.Panel)
+    .data(barley)
+    .height(h)
+    .left(90)
+    .top(lambda { self.index * h})
+    .stroke_style(pv.color("#999"));
+
+# Title bar. */
+cell.add(pv.Bar)
+    .height(14)
+    .fill_style("bisque")
+  .anchor("center").add(pv.Label)
+  .text(lambda{|site| site.key});
+
+# A dot showing the yield. */
+dot = cell.add(pv.Panel)
+.data(lambda {|site| site.values})
+    .top(23)
+  .add(pv.Dot)
+  .data(lambda {|year| year.values})
+  .left(lambda {|d| x.scale(d[:yield])})
+    .top(lambda {self.index * 11})
+    .shape_size(10)
+    .line_width(2)
+    .stroke_style(lambda {|d| c.scale(d[:year])})
+
+# A label showing the variety. */
+dot.anchor("left").add(pv.Label)
+  .visible(lambda { self.parent.index!=0})
+  .left(-2)
+  .text(lambda {|d| d[:variety]})
+
+# X-ticks. */
+vis.add(pv.Rule)
+    .data(x.ticks())
+    .left(lambda {|d|  90+x.scale(d)})
+    .bottom(-5)
+    .height(5)
+    .stroke_style("#999")
+  .anchor("bottom").add(pv.Label);
+
+# A legend showing the year. */
+vis.add(pv.Dot)
+    .mark_extend(dot)
+    .data([{:year=>1931}, {:year=>1932}])
+    .left(lambda {|d| 260 + self.index * 40})
+    .top(-8)
+  .anchor("right").add(pv.Label)
+  .text(lambda {|d| d[:year]})
+
+vis.render()
+
+puts vis.to_svg
\ No newline at end of file
diff --git a/examples/4_pv_custom/barley/barley_data.rb b/examples/4_pv_custom/barley/barley_data.rb
new file mode 100644
index 0000000..03c4de3
--- /dev/null
+++ b/examples/4_pv_custom/barley/barley_data.rb
@@ -0,0 +1,122 @@
+$barley = [
+  { yield: 27.00000, variety: "Manchuria", year: 1931, site: "University Farm" },
+  { yield: 48.86667, variety: "Manchuria", year: 1931, site: "Waseca" },
+  { yield: 27.43334, variety: "Manchuria", year: 1931, site: "Morris" },
+  { yield: 39.93333, variety: "Manchuria", year: 1931, site: "Crookston" },
+  { yield: 32.96667, variety: "Manchuria", year: 1931, site: "Grand Rapids" },
+  { yield: 28.96667, variety: "Manchuria", year: 1931, site: "Duluth" },
+  { yield: 43.06666, variety: "Glabron", year: 1931, site: "University Farm" },
+  { yield: 55.20000, variety: "Glabron", year: 1931, site: "Waseca" },
+  { yield: 28.76667, variety: "Glabron", year: 1931, site: "Morris" },
+  { yield: 38.13333, variety: "Glabron", year: 1931, site: "Crookston" },
+  { yield: 29.13333, variety: "Glabron", year: 1931, site: "Grand Rapids" },
+  { yield: 29.66667, variety: "Glabron", year: 1931, site: "Duluth" },
+  { yield: 35.13333, variety: "Svansota", year: 1931, site: "University Farm" },
+  { yield: 47.33333, variety: "Svansota", year: 1931, site: "Waseca" },
+  { yield: 25.76667, variety: "Svansota", year: 1931, site: "Morris" },
+  { yield: 40.46667, variety: "Svansota", year: 1931, site: "Crookston" },
+  { yield: 29.66667, variety: "Svansota", year: 1931, site: "Grand Rapids" },
+  { yield: 25.70000, variety: "Svansota", year: 1931, site: "Duluth" },
+  { yield: 39.90000, variety: "Velvet", year: 1931, site: "University Farm" },
+  { yield: 50.23333, variety: "Velvet", year: 1931, site: "Waseca" },
+  { yield: 26.13333, variety: "Velvet", year: 1931, site: "Morris" },
+  { yield: 41.33333, variety: "Velvet", year: 1931, site: "Crookston" },
+  { yield: 23.03333, variety: "Velvet", year: 1931, site: "Grand Rapids" },
+  { yield: 26.30000, variety: "Velvet", year: 1931, site: "Duluth" },
+  { yield: 36.56666, variety: "Trebi", year: 1931, site: "University Farm" },
+  { yield: 63.83330, variety: "Trebi", year: 1931, site: "Waseca" },
+  { yield: 43.76667, variety: "Trebi", year: 1931, site: "Morris" },
+  { yield: 46.93333, variety: "Trebi", year: 1931, site: "Crookston" },
+  { yield: 29.76667, variety: "Trebi", year: 1931, site: "Grand Rapids" },
+  { yield: 33.93333, variety: "Trebi", year: 1931, site: "Duluth" },
+  { yield: 43.26667, variety: "No. 457", year: 1931, site: "University Farm" },
+  { yield: 58.10000, variety: "No. 457", year: 1931, site: "Waseca" },
+  { yield: 28.70000, variety: "No. 457", year: 1931, site: "Morris" },
+  { yield: 45.66667, variety: "No. 457", year: 1931, site: "Crookston" },
+  { yield: 32.16667, variety: "No. 457", year: 1931, site: "Grand Rapids" },
+  { yield: 33.60000, variety: "No. 457", year: 1931, site: "Duluth" },
+  { yield: 36.60000, variety: "No. 462", year: 1931, site: "University Farm" },
+  { yield: 65.76670, variety: "No. 462", year: 1931, site: "Waseca" },
+  { yield: 30.36667, variety: "No. 462", year: 1931, site: "Morris" },
+  { yield: 48.56666, variety: "No. 462", year: 1931, site: "Crookston" },
+  { yield: 24.93334, variety: "No. 462", year: 1931, site: "Grand Rapids" },
+  { yield: 28.10000, variety: "No. 462", year: 1931, site: "Duluth" },
+  { yield: 32.76667, variety: "Peatland", year: 1931, site: "University Farm" },
+  { yield: 48.56666, variety: "Peatland", year: 1931, site: "Waseca" },
+  { yield: 29.86667, variety: "Peatland", year: 1931, site: "Morris" },
+  { yield: 41.60000, variety: "Peatland", year: 1931, site: "Crookston" },
+  { yield: 34.70000, variety: "Peatland", year: 1931, site: "Grand Rapids" },
+  { yield: 32.00000, variety: "Peatland", year: 1931, site: "Duluth" },
+  { yield: 24.66667, variety: "No. 475", year: 1931, site: "University Farm" },
+  { yield: 46.76667, variety: "No. 475", year: 1931, site: "Waseca" },
+  { yield: 22.60000, variety: "No. 475", year: 1931, site: "Morris" },
+  { yield: 44.10000, variety: "No. 475", year: 1931, site: "Crookston" },
+  { yield: 19.70000, variety: "No. 475", year: 1931, site: "Grand Rapids" },
+  { yield: 33.06666, variety: "No. 475", year: 1931, site: "Duluth" },
+  { yield: 39.30000, variety: "Wisconsin No. 38", year: 1931, site: "University Farm" },
+  { yield: 58.80000, variety: "Wisconsin No. 38", year: 1931, site: "Waseca" },
+  { yield: 29.46667, variety: "Wisconsin No. 38", year: 1931, site: "Morris" },
+  { yield: 49.86667, variety: "Wisconsin No. 38", year: 1931, site: "Crookston" },
+  { yield: 34.46667, variety: "Wisconsin No. 38", year: 1931, site: "Grand Rapids" },
+  { yield: 31.60000, variety: "Wisconsin No. 38", year: 1931, site: "Duluth" },
+  { yield: 26.90000, variety: "Manchuria", year: 1932, site: "University Farm" },
+  { yield: 33.46667, variety: "Manchuria", year: 1932, site: "Waseca" },
+  { yield: 34.36666, variety: "Manchuria", year: 1932, site: "Morris" },
+  { yield: 32.96667, variety: "Manchuria", year: 1932, site: "Crookston" },
+  { yield: 22.13333, variety: "Manchuria", year: 1932, site: "Grand Rapids" },
+  { yield: 22.56667, variety: "Manchuria", year: 1932, site: "Duluth" },
+  { yield: 36.80000, variety: "Glabron", year: 1932, site: "University Farm" },
+  { yield: 37.73333, variety: "Glabron", year: 1932, site: "Waseca" },
+  { yield: 35.13333, variety: "Glabron", year: 1932, site: "Morris" },
+  { yield: 26.16667, variety: "Glabron", year: 1932, site: "Crookston" },
+  { yield: 14.43333, variety: "Glabron", year: 1932, site: "Grand Rapids" },
+  { yield: 25.86667, variety: "Glabron", year: 1932, site: "Duluth" },
+  { yield: 27.43334, variety: "Svansota", year: 1932, site: "University Farm" },
+  { yield: 38.50000, variety: "Svansota", year: 1932, site: "Waseca" },
+  { yield: 35.03333, variety: "Svansota", year: 1932, site: "Morris" },
+  { yield: 20.63333, variety: "Svansota", year: 1932, site: "Crookston" },
+  { yield: 16.63333, variety: "Svansota", year: 1932, site: "Grand Rapids" },
+  { yield: 22.23333, variety: "Svansota", year: 1932, site: "Duluth" },
+  { yield: 26.80000, variety: "Velvet", year: 1932, site: "University Farm" },
+  { yield: 37.40000, variety: "Velvet", year: 1932, site: "Waseca" },
+  { yield: 38.83333, variety: "Velvet", year: 1932, site: "Morris" },
+  { yield: 32.06666, variety: "Velvet", year: 1932, site: "Crookston" },
+  { yield: 32.23333, variety: "Velvet", year: 1932, site: "Grand Rapids" },
+  { yield: 22.46667, variety: "Velvet", year: 1932, site: "Duluth" },
+  { yield: 29.06667, variety: "Trebi", year: 1932, site: "University Farm" },
+  { yield: 49.23330, variety: "Trebi", year: 1932, site: "Waseca" },
+  { yield: 46.63333, variety: "Trebi", year: 1932, site: "Morris" },
+  { yield: 41.83333, variety: "Trebi", year: 1932, site: "Crookston" },
+  { yield: 20.63333, variety: "Trebi", year: 1932, site: "Grand Rapids" },
+  { yield: 30.60000, variety: "Trebi", year: 1932, site: "Duluth" },
+  { yield: 26.43334, variety: "No. 457", year: 1932, site: "University Farm" },
+  { yield: 42.20000, variety: "No. 457", year: 1932, site: "Waseca" },
+  { yield: 43.53334, variety: "No. 457", year: 1932, site: "Morris" },
+  { yield: 34.33333, variety: "No. 457", year: 1932, site: "Crookston" },
+  { yield: 19.46667, variety: "No. 457", year: 1932, site: "Grand Rapids" },
+  { yield: 22.70000, variety: "No. 457", year: 1932, site: "Duluth" },
+  { yield: 25.56667, variety: "No. 462", year: 1932, site: "University Farm" },
+  { yield: 44.70000, variety: "No. 462", year: 1932, site: "Waseca" },
+  { yield: 47.00000, variety: "No. 462", year: 1932, site: "Morris" },
+  { yield: 30.53333, variety: "No. 462", year: 1932, site: "Crookston" },
+  { yield: 19.90000, variety: "No. 462", year: 1932, site: "Grand Rapids" },
+  { yield: 22.50000, variety: "No. 462", year: 1932, site: "Duluth" },
+  { yield: 28.06667, variety: "Peatland", year: 1932, site: "University Farm" },
+  { yield: 36.03333, variety: "Peatland", year: 1932, site: "Waseca" },
+  { yield: 43.20000, variety: "Peatland", year: 1932, site: "Morris" },
+  { yield: 25.23333, variety: "Peatland", year: 1932, site: "Crookston" },
+  { yield: 26.76667, variety: "Peatland", year: 1932, site: "Grand Rapids" },
+  { yield: 31.36667, variety: "Peatland", year: 1932, site: "Duluth" },
+  { yield: 30.00000, variety: "No. 475", year: 1932, site: "University Farm" },
+  { yield: 41.26667, variety: "No. 475", year: 1932, site: "Waseca" },
+  { yield: 44.23333, variety: "No. 475", year: 1932, site: "Morris" },
+  { yield: 32.13333, variety: "No. 475", year: 1932, site: "Crookston" },
+  { yield: 15.23333, variety: "No. 475", year: 1932, site: "Grand Rapids" },
+  { yield: 27.36667, variety: "No. 475", year: 1932, site: "Duluth" },
+  { yield: 38.00000, variety: "Wisconsin No. 38", year: 1932, site: "University Farm" },
+  { yield: 58.16667, variety: "Wisconsin No. 38", year: 1932, site: "Waseca" },
+  { yield: 47.16667, variety: "Wisconsin No. 38", year: 1932, site: "Morris" },
+  { yield: 35.90000, variety: "Wisconsin No. 38", year: 1932, site: "Crookston" },
+  { yield: 20.66667, variety: "Wisconsin No. 38", year: 1932, site: "Grand Rapids" },
+  { yield: 29.33333, variety: "Wisconsin No. 38", year: 1932, site: "Duluth" }
+];
\ No newline at end of file
diff --git a/examples/4_pv_custom/cars/cars.rb b/examples/4_pv_custom/cars/cars.rb
new file mode 100644
index 0000000..446616d
--- /dev/null
+++ b/examples/4_pv_custom/cars/cars.rb
@@ -0,0 +1,90 @@
+# = Parallel Coordinates
+# Parallel coordinates is a popular method of visualizing high-dimensional data using dynamic queries. 
+# On static setting, you could choose an attribute and colour each datum which belongs to an attribute differently. On this example, we choose to color :cylinders attribute and highlight the cars with 8 cylinders
+
+$:.unshift(File.dirname(__FILE__)+"/../../../lib")
+require 'rubyvis'
+load(File.dirname(__FILE__)+"/cars_data.rb")
+attr_to_color=:cylinders
+highlighted=lambda {|d|
+  d[:cylinders].to_i==8
+}
+
+dims = [
+  :cylinders,
+  :displacement,
+  :weight,
+  :horsepower,
+  :acceleration,
+  :mpg,
+  :year,
+  :origin
+];
+
+# Sizing and scales. */
+w = 840
+h = 420
+color = Rubyvis.Colors.category10()
+car_color = Rubyvis.Colors.category10()
+x = Rubyvis.Scale.ordinal(dims).split_flush(0, w)
+y = Rubyvis.dict(dims, lambda {|t|
+    Rubyvis.Scale.linear().
+      domain($cars.find_all {|d| !d[t].nil?} ,
+        lambda {|d| d[t]}).range(0, h)
+    })
+
+#/* The root panel. */
+vis=Rubyvis::Panel.new do 
+  width w 
+  height h 
+  margin 20 
+  bottom 40 
+  # Rule and labels per dimension
+  rule do 
+    data(dims)
+    left(x)
+    stroke_style(lambda {|d| color.scale(index)})
+    line_width(2)
+    # Min value
+    label(:anchor=>'bottom') do
+      text {|t|
+        y[t].tick_format.call(y[t].domain()[0])
+      }
+    end
+    # Max value
+    label(:anchor=>'top') do
+      text {
+        |t| y[t].tick_format.call(y[t].domain()[1])
+      }
+    end
+    # Dim name
+    label(:anchor=>'bottom') do
+      text_style {color.scale(index).darker}
+      text_margin 14
+    end
+  end
+  # Parallel coordinates.
+  panel do
+    # Each car generate a panel
+    data($cars)
+    line do
+      # Inside each car, every dimension generate a point
+      data(dims)
+      left {|t, d| x.scale(t)}
+      bottom {|t, d|  y[t].scale(d[t])}
+      line_width {|t,d| 
+        highlighted.call(d) ? 4 : 1
+      }
+      stroke_style {|t,d|
+        # Highlighted items will be opaquer
+        alpha=highlighted.call(d) ? 0.4 : 0.1
+        car_color.scale(d[attr_to_color]).alpha(alpha)
+      }
+      line_width(1)
+    end
+  end
+end
+
+
+vis.render()
+puts vis.to_svg
diff --git a/examples/4_pv_custom/cars/cars_data.rb b/examples/4_pv_custom/cars/cars_data.rb
new file mode 100644
index 0000000..cb51d71
--- /dev/null
+++ b/examples/4_pv_custom/cars/cars_data.rb
@@ -0,0 +1,409 @@
+$cars = [
+{:name=>"chevrolet chevelle malibu", :mpg=>18, :cylinders=>8, :displacement=>307, :horsepower=>130, :weight=>3504, :acceleration=>12, :year=>70, :origin=>1},
+{:name=>"buick skylark 320", :mpg=>15, :cylinders=>8, :displacement=>350, :horsepower=>165, :weight=>3693, :acceleration=>11.5, :year=>70, :origin=>1},
+{:name=>"plymouth satellite", :mpg=>18, :cylinders=>8, :displacement=>318, :horsepower=>150, :weight=>3436, :acceleration=>11, :year=>70, :origin=>1},
+{:name=>"amc rebel sst", :mpg=>16, :cylinders=>8, :displacement=>304, :horsepower=>150, :weight=>3433, :acceleration=>12, :year=>70, :origin=>1},
+{:name=>"ford torino", :mpg=>17, :cylinders=>8, :displacement=>302, :horsepower=>140, :weight=>3449, :acceleration=>10.5, :year=>70, :origin=>1},
+{:name=>"ford galaxie 500", :mpg=>15, :cylinders=>8, :displacement=>429, :horsepower=>198, :weight=>4341, :acceleration=>10, :year=>70, :origin=>1},
+{:name=>"chevrolet impala", :mpg=>14, :cylinders=>8, :displacement=>454, :horsepower=>220, :weight=>4354, :acceleration=>9, :year=>70, :origin=>1},
+{:name=>"plymouth fury iii", :mpg=>14, :cylinders=>8, :displacement=>440, :horsepower=>215, :weight=>4312, :acceleration=>8.5, :year=>70, :origin=>1},
+{:name=>"pontiac catalina", :mpg=>14, :cylinders=>8, :displacement=>455, :horsepower=>225, :weight=>4425, :acceleration=>10, :year=>70, :origin=>1},
+{:name=>"amc ambassador dpl", :mpg=>15, :cylinders=>8, :displacement=>390, :horsepower=>190, :weight=>3850, :acceleration=>8.5, :year=>70, :origin=>1},
+{:name=>"citroen ds-21 pallas", :mpg=>nil, :cylinders=>4, :displacement=>133, :horsepower=>115, :weight=>3090, :acceleration=>17.5, :year=>70, :origin=>2},
+{:name=>"chevrolet chevelle concours (sw)", :mpg=>nil, :cylinders=>8, :displacement=>350, :horsepower=>165, :weight=>4142, :acceleration=>11.5, :year=>70, :origin=>1},
+{:name=>"ford torino (sw)", :mpg=>nil, :cylinders=>8, :displacement=>351, :horsepower=>153, :weight=>4034, :acceleration=>11, :year=>70, :origin=>1},
+{:name=>"plymouth satellite (sw)", :mpg=>nil, :cylinders=>8, :displacement=>383, :horsepower=>175, :weight=>4166, :acceleration=>10.5, :year=>70, :origin=>1},
+{:name=>"amc rebel sst (sw)", :mpg=>nil, :cylinders=>8, :displacement=>360, :horsepower=>175, :weight=>3850, :acceleration=>11, :year=>70, :origin=>1},
+{:name=>"dodge challenger se", :mpg=>15, :cylinders=>8, :displacement=>383, :horsepower=>170, :weight=>3563, :acceleration=>10, :year=>70, :origin=>1},
+{:name=>"plymouth 'cuda 340", :mpg=>14, :cylinders=>8, :displacement=>340, :horsepower=>160, :weight=>3609, :acceleration=>8, :year=>70, :origin=>1},
+{:name=>"ford mustang boss 302", :mpg=>nil, :cylinders=>8, :displacement=>302, :horsepower=>140, :weight=>3353, :acceleration=>8, :year=>70, :origin=>1},
+{:name=>"chevrolet monte carlo", :mpg=>15, :cylinders=>8, :displacement=>400, :horsepower=>150, :weight=>3761, :acceleration=>9.5, :year=>70, :origin=>1},
+{:name=>"buick estate wagon (sw)", :mpg=>14, :cylinders=>8, :displacement=>455, :horsepower=>225, :weight=>3086, :acceleration=>10, :year=>70, :origin=>1},
+{:name=>"toyota corona mark ii", :mpg=>24, :cylinders=>4, :displacement=>113, :horsepower=>95, :weight=>2372, :acceleration=>15, :year=>70, :origin=>3},
+{:name=>"plymouth duster", :mpg=>22, :cylinders=>6, :displacement=>198, :horsepower=>95, :weight=>2833, :acceleration=>15.5, :year=>70, :origin=>1},
+{:name=>"amc hornet", :mpg=>18, :cylinders=>6, :displacement=>199, :horsepower=>97, :weight=>2774, :acceleration=>15.5, :year=>70, :origin=>1},
+{:name=>"ford maverick", :mpg=>21, :cylinders=>6, :displacement=>200, :horsepower=>85, :weight=>2587, :acceleration=>16, :year=>70, :origin=>1},
+{:name=>"datsun pl510", :mpg=>27, :cylinders=>4, :displacement=>97, :horsepower=>88, :weight=>2130, :acceleration=>14.5, :year=>70, :origin=>3},
+{:name=>"volkswagen 1131 deluxe sedan", :mpg=>26, :cylinders=>4, :displacement=>97, :horsepower=>46, :weight=>1835, :acceleration=>20.5, :year=>70, :origin=>2},
+{:name=>"peugeot 504", :mpg=>25, :cylinders=>4, :displacement=>110, :horsepower=>87, :weight=>2672, :acceleration=>17.5, :year=>70, :origin=>2},
+{:name=>"audi 100 ls", :mpg=>24, :cylinders=>4, :displacement=>107, :horsepower=>90, :weight=>2430, :acceleration=>14.5, :year=>70, :origin=>2},
+{:name=>"saab 99e", :mpg=>25, :cylinders=>4, :displacement=>104, :horsepower=>95, :weight=>2375, :acceleration=>17.5, :year=>70, :origin=>2},
+{:name=>"bmw 2002", :mpg=>26, :cylinders=>4, :displacement=>121, :horsepower=>113, :weight=>2234, :acceleration=>12.5, :year=>70, :origin=>2},
+{:name=>"amc gremlin", :mpg=>21, :cylinders=>6, :displacement=>199, :horsepower=>90, :weight=>2648, :acceleration=>15, :year=>70, :origin=>1},
+{:name=>"ford f250", :mpg=>10, :cylinders=>8, :displacement=>360, :horsepower=>215, :weight=>4615, :acceleration=>14, :year=>70, :origin=>1},
+{:name=>"chevy c20", :mpg=>10, :cylinders=>8, :displacement=>307, :horsepower=>200, :weight=>4376, :acceleration=>15, :year=>70, :origin=>1},
+{:name=>"dodge d200", :mpg=>11, :cylinders=>8, :displacement=>318, :horsepower=>210, :weight=>4382, :acceleration=>13.5, :year=>70, :origin=>1},
+{:name=>"hi 1200d", :mpg=>9, :cylinders=>8, :displacement=>304, :horsepower=>193, :weight=>4732, :acceleration=>18.5, :year=>70, :origin=>1},
+{:name=>"datsun pl510", :mpg=>27, :cylinders=>4, :displacement=>97, :horsepower=>88, :weight=>2130, :acceleration=>14.5, :year=>71, :origin=>3},
+{:name=>"chevrolet vega 2300", :mpg=>28, :cylinders=>4, :displacement=>140, :horsepower=>90, :weight=>2264, :acceleration=>15.5, :year=>71, :origin=>1},
+{:name=>"toyota corona", :mpg=>25, :cylinders=>4, :displacement=>113, :horsepower=>95, :weight=>2228, :acceleration=>14, :year=>71, :origin=>3},
+{:name=>"ford pinto", :mpg=>25, :cylinders=>4, :displacement=>98, :horsepower=>nil, :weight=>2046, :acceleration=>19, :year=>71, :origin=>1},
+{:name=>"volkswagen super beetle 117", :mpg=>nil, :cylinders=>4, :displacement=>97, :horsepower=>48, :weight=>1978, :acceleration=>20, :year=>71, :origin=>2},
+{:name=>"amc gremlin", :mpg=>19, :cylinders=>6, :displacement=>232, :horsepower=>100, :weight=>2634, :acceleration=>13, :year=>71, :origin=>1},
+{:name=>"plymouth satellite custom", :mpg=>16, :cylinders=>6, :displacement=>225, :horsepower=>105, :weight=>3439, :acceleration=>15.5, :year=>71, :origin=>1},
+{:name=>"chevrolet chevelle malibu", :mpg=>17, :cylinders=>6, :displacement=>250, :horsepower=>100, :weight=>3329, :acceleration=>15.5, :year=>71, :origin=>1},
+{:name=>"ford torino 500", :mpg=>19, :cylinders=>6, :displacement=>250, :horsepower=>88, :weight=>3302, :acceleration=>15.5, :year=>71, :origin=>1},
+{:name=>"amc matador", :mpg=>18, :cylinders=>6, :displacement=>232, :horsepower=>100, :weight=>3288, :acceleration=>15.5, :year=>71, :origin=>1},
+{:name=>"chevrolet impala", :mpg=>14, :cylinders=>8, :displacement=>350, :horsepower=>165, :weight=>4209, :acceleration=>12, :year=>71, :origin=>1},
+{:name=>"pontiac catalina brougham", :mpg=>14, :cylinders=>8, :displacement=>400, :horsepower=>175, :weight=>4464, :acceleration=>11.5, :year=>71, :origin=>1},
+{:name=>"ford galaxie 500", :mpg=>14, :cylinders=>8, :displacement=>351, :horsepower=>153, :weight=>4154, :acceleration=>13.5, :year=>71, :origin=>1},
+{:name=>"plymouth fury iii", :mpg=>14, :cylinders=>8, :displacement=>318, :horsepower=>150, :weight=>4096, :acceleration=>13, :year=>71, :origin=>1},
+{:name=>"dodge monaco (sw)", :mpg=>12, :cylinders=>8, :displacement=>383, :horsepower=>180, :weight=>4955, :acceleration=>11.5, :year=>71, :origin=>1},
+{:name=>"ford country squire (sw)", :mpg=>13, :cylinders=>8, :displacement=>400, :horsepower=>170, :weight=>4746, :acceleration=>12, :year=>71, :origin=>1},
+{:name=>"pontiac safari (sw)", :mpg=>13, :cylinders=>8, :displacement=>400, :horsepower=>175, :weight=>5140, :acceleration=>12, :year=>71, :origin=>1},
+{:name=>"amc hornet sportabout (sw)", :mpg=>18, :cylinders=>6, :displacement=>258, :horsepower=>110, :weight=>2962, :acceleration=>13.5, :year=>71, :origin=>1},
+{:name=>"chevrolet vega (sw)", :mpg=>22, :cylinders=>4, :displacement=>140, :horsepower=>72, :weight=>2408, :acceleration=>19, :year=>71, :origin=>1},
+{:name=>"pontiac firebird", :mpg=>19, :cylinders=>6, :displacement=>250, :horsepower=>100, :weight=>3282, :acceleration=>15, :year=>71, :origin=>1},
+{:name=>"ford mustang", :mpg=>18, :cylinders=>6, :displacement=>250, :horsepower=>88, :weight=>3139, :acceleration=>14.5, :year=>71, :origin=>1},
+{:name=>"mercury capri 2000", :mpg=>23, :cylinders=>4, :displacement=>122, :horsepower=>86, :weight=>2220, :acceleration=>14, :year=>71, :origin=>1},
+{:name=>"opel 1900", :mpg=>28, :cylinders=>4, :displacement=>116, :horsepower=>90, :weight=>2123, :acceleration=>14, :year=>71, :origin=>2},
+{:name=>"peugeot 304", :mpg=>30, :cylinders=>4, :displacement=>79, :horsepower=>70, :weight=>2074, :acceleration=>19.5, :year=>71, :origin=>2},
+{:name=>"fiat 124b", :mpg=>30, :cylinders=>4, :displacement=>88, :horsepower=>76, :weight=>2065, :acceleration=>14.5, :year=>71, :origin=>2},
+{:name=>"toyota corolla 1200", :mpg=>31, :cylinders=>4, :displacement=>71, :horsepower=>65, :weight=>1773, :acceleration=>19, :year=>71, :origin=>3},
+{:name=>"datsun 1200", :mpg=>35, :cylinders=>4, :displacement=>72, :horsepower=>69, :weight=>1613, :acceleration=>18, :year=>71, :origin=>3},
+{:name=>"volkswagen model 111", :mpg=>27, :cylinders=>4, :displacement=>97, :horsepower=>60, :weight=>1834, :acceleration=>19, :year=>71, :origin=>2},
+{:name=>"plymouth cricket", :mpg=>26, :cylinders=>4, :displacement=>91, :horsepower=>70, :weight=>1955, :acceleration=>20.5, :year=>71, :origin=>1},
+{:name=>"toyota corona hardtop", :mpg=>24, :cylinders=>4, :displacement=>113, :horsepower=>95, :weight=>2278, :acceleration=>15.5, :year=>72, :origin=>3},
+{:name=>"dodge colt hardtop", :mpg=>25, :cylinders=>4, :displacement=>97.5, :horsepower=>80, :weight=>2126, :acceleration=>17, :year=>72, :origin=>1},
+{:name=>"volkswagen type 3", :mpg=>23, :cylinders=>4, :displacement=>97, :horsepower=>54, :weight=>2254, :acceleration=>23.5, :year=>72, :origin=>2},
+{:name=>"chevrolet vega", :mpg=>20, :cylinders=>4, :displacement=>140, :horsepower=>90, :weight=>2408, :acceleration=>19.5, :year=>72, :origin=>1},
+{:name=>"ford pinto runabout", :mpg=>21, :cylinders=>4, :displacement=>122, :horsepower=>86, :weight=>2226, :acceleration=>16.5, :year=>72, :origin=>1},
+{:name=>"chevrolet impala", :mpg=>13, :cylinders=>8, :displacement=>350, :horsepower=>165, :weight=>4274, :acceleration=>12, :year=>72, :origin=>1},
+{:name=>"pontiac catalina", :mpg=>14, :cylinders=>8, :displacement=>400, :horsepower=>175, :weight=>4385, :acceleration=>12, :year=>72, :origin=>1},
+{:name=>"plymouth fury iii", :mpg=>15, :cylinders=>8, :displacement=>318, :horsepower=>150, :weight=>4135, :acceleration=>13.5, :year=>72, :origin=>1},
+{:name=>"ford galaxie 500", :mpg=>14, :cylinders=>8, :displacement=>351, :horsepower=>153, :weight=>4129, :acceleration=>13, :year=>72, :origin=>1},
+{:name=>"amc ambassador sst", :mpg=>17, :cylinders=>8, :displacement=>304, :horsepower=>150, :weight=>3672, :acceleration=>11.5, :year=>72, :origin=>1},
+{:name=>"mercury marquis", :mpg=>11, :cylinders=>8, :displacement=>429, :horsepower=>208, :weight=>4633, :acceleration=>11, :year=>72, :origin=>1},
+{:name=>"buick lesabre custom", :mpg=>13, :cylinders=>8, :displacement=>350, :horsepower=>155, :weight=>4502, :acceleration=>13.5, :year=>72, :origin=>1},
+{:name=>"oldsmobile delta 88 royale", :mpg=>12, :cylinders=>8, :displacement=>350, :horsepower=>160, :weight=>4456, :acceleration=>13.5, :year=>72, :origin=>1},
+{:name=>"chrysler newport royal", :mpg=>13, :cylinders=>8, :displacement=>400, :horsepower=>190, :weight=>4422, :acceleration=>12.5, :year=>72, :origin=>1},
+{:name=>"mazda rx2 coupe", :mpg=>19, :cylinders=>3, :displacement=>70, :horsepower=>97, :weight=>2330, :acceleration=>13.5, :year=>72, :origin=>3},
+{:name=>"amc matador (sw)", :mpg=>15, :cylinders=>8, :displacement=>304, :horsepower=>150, :weight=>3892, :acceleration=>12.5, :year=>72, :origin=>1},
+{:name=>"chevrolet chevelle concours (sw)", :mpg=>13, :cylinders=>8, :displacement=>307, :horsepower=>130, :weight=>4098, :acceleration=>14, :year=>72, :origin=>1},
+{:name=>"ford gran torino (sw)", :mpg=>13, :cylinders=>8, :displacement=>302, :horsepower=>140, :weight=>4294, :acceleration=>16, :year=>72, :origin=>1},
+{:name=>"plymouth satellite custom (sw)", :mpg=>14, :cylinders=>8, :displacement=>318, :horsepower=>150, :weight=>4077, :acceleration=>14, :year=>72, :origin=>1},
+{:name=>"volvo 145e (sw)", :mpg=>18, :cylinders=>4, :displacement=>121, :horsepower=>112, :weight=>2933, :acceleration=>14.5, :year=>72, :origin=>2},
+{:name=>"volkswagen 411 (sw)", :mpg=>22, :cylinders=>4, :displacement=>121, :horsepower=>76, :weight=>2511, :acceleration=>18, :year=>72, :origin=>2},
+{:name=>"peugeot 504 (sw)", :mpg=>21, :cylinders=>4, :displacement=>120, :horsepower=>87, :weight=>2979, :acceleration=>19.5, :year=>72, :origin=>2},
+{:name=>"renault 12 (sw)", :mpg=>26, :cylinders=>4, :displacement=>96, :horsepower=>69, :weight=>2189, :acceleration=>18, :year=>72, :origin=>2},
+{:name=>"ford pinto (sw)", :mpg=>22, :cylinders=>4, :displacement=>122, :horsepower=>86, :weight=>2395, :acceleration=>16, :year=>72, :origin=>1},
+{:name=>"datsun 510 (sw)", :mpg=>28, :cylinders=>4, :displacement=>97, :horsepower=>92, :weight=>2288, :acceleration=>17, :year=>72, :origin=>3},
+{:name=>"toyouta corona mark ii (sw)", :mpg=>23, :cylinders=>4, :displacement=>120, :horsepower=>97, :weight=>2506, :acceleration=>14.5, :year=>72, :origin=>3},
+{:name=>"dodge colt (sw)", :mpg=>28, :cylinders=>4, :displacement=>98, :horsepower=>80, :weight=>2164, :acceleration=>15, :year=>72, :origin=>1},
+{:name=>"toyota corolla 1600 (sw)", :mpg=>27, :cylinders=>4, :displacement=>97, :horsepower=>88, :weight=>2100, :acceleration=>16.5, :year=>72, :origin=>3},
+{:name=>"buick century 350", :mpg=>13, :cylinders=>8, :displacement=>350, :horsepower=>175, :weight=>4100, :acceleration=>13, :year=>73, :origin=>1},
+{:name=>"amc matador", :mpg=>14, :cylinders=>8, :displacement=>304, :horsepower=>150, :weight=>3672, :acceleration=>11.5, :year=>73, :origin=>1},
+{:name=>"chevrolet malibu", :mpg=>13, :cylinders=>8, :displacement=>350, :horsepower=>145, :weight=>3988, :acceleration=>13, :year=>73, :origin=>1},
+{:name=>"ford gran torino", :mpg=>14, :cylinders=>8, :displacement=>302, :horsepower=>137, :weight=>4042, :acceleration=>14.5, :year=>73, :origin=>1},
+{:name=>"dodge coronet custom", :mpg=>15, :cylinders=>8, :displacement=>318, :horsepower=>150, :weight=>3777, :acceleration=>12.5, :year=>73, :origin=>1},
+{:name=>"mercury marquis brougham", :mpg=>12, :cylinders=>8, :displacement=>429, :horsepower=>198, :weight=>4952, :acceleration=>11.5, :year=>73, :origin=>1},
+{:name=>"chevrolet caprice classic", :mpg=>13, :cylinders=>8, :displacement=>400, :horsepower=>150, :weight=>4464, :acceleration=>12, :year=>73, :origin=>1},
+{:name=>"ford ltd", :mpg=>13, :cylinders=>8, :displacement=>351, :horsepower=>158, :weight=>4363, :acceleration=>13, :year=>73, :origin=>1},
+{:name=>"plymouth fury gran sedan", :mpg=>14, :cylinders=>8, :displacement=>318, :horsepower=>150, :weight=>4237, :acceleration=>14.5, :year=>73, :origin=>1},
+{:name=>"chrysler new yorker brougham", :mpg=>13, :cylinders=>8, :displacement=>440, :horsepower=>215, :weight=>4735, :acceleration=>11, :year=>73, :origin=>1},
+{:name=>"buick electra 225 custom", :mpg=>12, :cylinders=>8, :displacement=>455, :horsepower=>225, :weight=>4951, :acceleration=>11, :year=>73, :origin=>1},
+{:name=>"amc ambassador brougham", :mpg=>13, :cylinders=>8, :displacement=>360, :horsepower=>175, :weight=>3821, :acceleration=>11, :year=>73, :origin=>1},
+{:name=>"plymouth valiant", :mpg=>18, :cylinders=>6, :displacement=>225, :horsepower=>105, :weight=>3121, :acceleration=>16.5, :year=>73, :origin=>1},
+{:name=>"chevrolet nova custom", :mpg=>16, :cylinders=>6, :displacement=>250, :horsepower=>100, :weight=>3278, :acceleration=>18, :year=>73, :origin=>1},
+{:name=>"amc hornet", :mpg=>18, :cylinders=>6, :displacement=>232, :horsepower=>100, :weight=>2945, :acceleration=>16, :year=>73, :origin=>1},
+{:name=>"ford maverick", :mpg=>18, :cylinders=>6, :displacement=>250, :horsepower=>88, :weight=>3021, :acceleration=>16.5, :year=>73, :origin=>1},
+{:name=>"plymouth duster", :mpg=>23, :cylinders=>6, :displacement=>198, :horsepower=>95, :weight=>2904, :acceleration=>16, :year=>73, :origin=>1},
+{:name=>"volkswagen super beetle", :mpg=>26, :cylinders=>4, :displacement=>97, :horsepower=>46, :weight=>1950, :acceleration=>21, :year=>73, :origin=>2},
+{:name=>"chevrolet impala", :mpg=>11, :cylinders=>8, :displacement=>400, :horsepower=>150, :weight=>4997, :acceleration=>14, :year=>73, :origin=>1},
+{:name=>"ford country", :mpg=>12, :cylinders=>8, :displacement=>400, :horsepower=>167, :weight=>4906, :acceleration=>12.5, :year=>73, :origin=>1},
+{:name=>"plymouth custom suburb", :mpg=>13, :cylinders=>8, :displacement=>360, :horsepower=>170, :weight=>4654, :acceleration=>13, :year=>73, :origin=>1},
+{:name=>"oldsmobile vista cruiser", :mpg=>12, :cylinders=>8, :displacement=>350, :horsepower=>180, :weight=>4499, :acceleration=>12.5, :year=>73, :origin=>1},
+{:name=>"amc gremlin", :mpg=>18, :cylinders=>6, :displacement=>232, :horsepower=>100, :weight=>2789, :acceleration=>15, :year=>73, :origin=>1},
+{:name=>"toyota carina", :mpg=>20, :cylinders=>4, :displacement=>97, :horsepower=>88, :weight=>2279, :acceleration=>19, :year=>73, :origin=>3},
+{:name=>"chevrolet vega", :mpg=>21, :cylinders=>4, :displacement=>140, :horsepower=>72, :weight=>2401, :acceleration=>19.5, :year=>73, :origin=>1},
+{:name=>"datsun 610", :mpg=>22, :cylinders=>4, :displacement=>108, :horsepower=>94, :weight=>2379, :acceleration=>16.5, :year=>73, :origin=>3},
+{:name=>"maxda rx3", :mpg=>18, :cylinders=>3, :displacement=>70, :horsepower=>90, :weight=>2124, :acceleration=>13.5, :year=>73, :origin=>3},
+{:name=>"ford pinto", :mpg=>19, :cylinders=>4, :displacement=>122, :horsepower=>85, :weight=>2310, :acceleration=>18.5, :year=>73, :origin=>1},
+{:name=>"mercury capri v6", :mpg=>21, :cylinders=>6, :displacement=>155, :horsepower=>107, :weight=>2472, :acceleration=>14, :year=>73, :origin=>1},
+{:name=>"fiat 124 sport coupe", :mpg=>26, :cylinders=>4, :displacement=>98, :horsepower=>90, :weight=>2265, :acceleration=>15.5, :year=>73, :origin=>2},
+{:name=>"chevrolet monte carlo s", :mpg=>15, :cylinders=>8, :displacement=>350, :horsepower=>145, :weight=>4082, :acceleration=>13, :year=>73, :origin=>1},
+{:name=>"pontiac grand prix", :mpg=>16, :cylinders=>8, :displacement=>400, :horsepower=>230, :weight=>4278, :acceleration=>9.5, :year=>73, :origin=>1},
+{:name=>"fiat 128", :mpg=>29, :cylinders=>4, :displacement=>68, :horsepower=>49, :weight=>1867, :acceleration=>19.5, :year=>73, :origin=>2},
+{:name=>"opel manta", :mpg=>24, :cylinders=>4, :displacement=>116, :horsepower=>75, :weight=>2158, :acceleration=>15.5, :year=>73, :origin=>2},
+{:name=>"audi 100ls", :mpg=>20, :cylinders=>4, :displacement=>114, :horsepower=>91, :weight=>2582, :acceleration=>14, :year=>73, :origin=>2},
+{:name=>"volvo 144ea", :mpg=>19, :cylinders=>4, :displacement=>121, :horsepower=>112, :weight=>2868, :acceleration=>15.5, :year=>73, :origin=>2},
+{:name=>"dodge dart custom", :mpg=>15, :cylinders=>8, :displacement=>318, :horsepower=>150, :weight=>3399, :acceleration=>11, :year=>73, :origin=>1},
+{:name=>"saab 99le", :mpg=>24, :cylinders=>4, :displacement=>121, :horsepower=>110, :weight=>2660, :acceleration=>14, :year=>73, :origin=>2},
+{:name=>"toyota mark ii", :mpg=>20, :cylinders=>6, :displacement=>156, :horsepower=>122, :weight=>2807, :acceleration=>13.5, :year=>73, :origin=>3},
+{:name=>"oldsmobile omega", :mpg=>11, :cylinders=>8, :displacement=>350, :horsepower=>180, :weight=>3664, :acceleration=>11, :year=>73, :origin=>1},
+{:name=>"plymouth duster", :mpg=>20, :cylinders=>6, :displacement=>198, :horsepower=>95, :weight=>3102, :acceleration=>16.5, :year=>74, :origin=>1},
+{:name=>"ford maverick", :mpg=>21, :cylinders=>6, :displacement=>200, :horsepower=>nil, :weight=>2875, :acceleration=>17, :year=>74, :origin=>1},
+{:name=>"amc hornet", :mpg=>19, :cylinders=>6, :displacement=>232, :horsepower=>100, :weight=>2901, :acceleration=>16, :year=>74, :origin=>1},
+{:name=>"chevrolet nova", :mpg=>15, :cylinders=>6, :displacement=>250, :horsepower=>100, :weight=>3336, :acceleration=>17, :year=>74, :origin=>1},
+{:name=>"datsun b210", :mpg=>31, :cylinders=>4, :displacement=>79, :horsepower=>67, :weight=>1950, :acceleration=>19, :year=>74, :origin=>3},
+{:name=>"ford pinto", :mpg=>26, :cylinders=>4, :displacement=>122, :horsepower=>80, :weight=>2451, :acceleration=>16.5, :year=>74, :origin=>1},
+{:name=>"toyota corolla 1200", :mpg=>32, :cylinders=>4, :displacement=>71, :horsepower=>65, :weight=>1836, :acceleration=>21, :year=>74, :origin=>3},
+{:name=>"chevrolet vega", :mpg=>25, :cylinders=>4, :displacement=>140, :horsepower=>75, :weight=>2542, :acceleration=>17, :year=>74, :origin=>1},
+{:name=>"chevrolet chevelle malibu classic", :mpg=>16, :cylinders=>6, :displacement=>250, :horsepower=>100, :weight=>3781, :acceleration=>17, :year=>74, :origin=>1},
+{:name=>"amc matador", :mpg=>16, :cylinders=>6, :displacement=>258, :horsepower=>110, :weight=>3632, :acceleration=>18, :year=>74, :origin=>1},
+{:name=>"plymouth satellite sebring", :mpg=>18, :cylinders=>6, :displacement=>225, :horsepower=>105, :weight=>3613, :acceleration=>16.5, :year=>74, :origin=>1},
+{:name=>"ford gran torino", :mpg=>16, :cylinders=>8, :displacement=>302, :horsepower=>140, :weight=>4141, :acceleration=>14, :year=>74, :origin=>1},
+{:name=>"buick century luxus (sw)", :mpg=>13, :cylinders=>8, :displacement=>350, :horsepower=>150, :weight=>4699, :acceleration=>14.5, :year=>74, :origin=>1},
+{:name=>"dodge coronet custom (sw)", :mpg=>14, :cylinders=>8, :displacement=>318, :horsepower=>150, :weight=>4457, :acceleration=>13.5, :year=>74, :origin=>1},
+{:name=>"ford gran torino (sw)", :mpg=>14, :cylinders=>8, :displacement=>302, :horsepower=>140, :weight=>4638, :acceleration=>16, :year=>74, :origin=>1},
+{:name=>"amc matador (sw)", :mpg=>14, :cylinders=>8, :displacement=>304, :horsepower=>150, :weight=>4257, :acceleration=>15.5, :year=>74, :origin=>1},
+{:name=>"audi fox", :mpg=>29, :cylinders=>4, :displacement=>98, :horsepower=>83, :weight=>2219, :acceleration=>16.5, :year=>74, :origin=>2},
+{:name=>"volkswagen dasher", :mpg=>26, :cylinders=>4, :displacement=>79, :horsepower=>67, :weight=>1963, :acceleration=>15.5, :year=>74, :origin=>2},
+{:name=>"opel manta", :mpg=>26, :cylinders=>4, :displacement=>97, :horsepower=>78, :weight=>2300, :acceleration=>14.5, :year=>74, :origin=>2},
+{:name=>"toyota corona", :mpg=>31, :cylinders=>4, :displacement=>76, :horsepower=>52, :weight=>1649, :acceleration=>16.5, :year=>74, :origin=>3},
+{:name=>"datsun 710", :mpg=>32, :cylinders=>4, :displacement=>83, :horsepower=>61, :weight=>2003, :acceleration=>19, :year=>74, :origin=>3},
+{:name=>"dodge colt", :mpg=>28, :cylinders=>4, :displacement=>90, :horsepower=>75, :weight=>2125, :acceleration=>14.5, :year=>74, :origin=>1},
+{:name=>"fiat 128", :mpg=>24, :cylinders=>4, :displacement=>90, :horsepower=>75, :weight=>2108, :acceleration=>15.5, :year=>74, :origin=>2},
+{:name=>"fiat 124 tc", :mpg=>26, :cylinders=>4, :displacement=>116, :horsepower=>75, :weight=>2246, :acceleration=>14, :year=>74, :origin=>2},
+{:name=>"honda civic", :mpg=>24, :cylinders=>4, :displacement=>120, :horsepower=>97, :weight=>2489, :acceleration=>15, :year=>74, :origin=>3},
+{:name=>"subaru", :mpg=>26, :cylinders=>4, :displacement=>108, :horsepower=>93, :weight=>2391, :acceleration=>15.5, :year=>74, :origin=>3},
+{:name=>"fiat x1.9", :mpg=>31, :cylinders=>4, :displacement=>79, :horsepower=>67, :weight=>2000, :acceleration=>16, :year=>74, :origin=>2},
+{:name=>"plymouth valiant custom", :mpg=>19, :cylinders=>6, :displacement=>225, :horsepower=>95, :weight=>3264, :acceleration=>16, :year=>75, :origin=>1},
+{:name=>"chevrolet nova", :mpg=>18, :cylinders=>6, :displacement=>250, :horsepower=>105, :weight=>3459, :acceleration=>16, :year=>75, :origin=>1},
+{:name=>"mercury monarch", :mpg=>15, :cylinders=>6, :displacement=>250, :horsepower=>72, :weight=>3432, :acceleration=>21, :year=>75, :origin=>1},
+{:name=>"ford maverick", :mpg=>15, :cylinders=>6, :displacement=>250, :horsepower=>72, :weight=>3158, :acceleration=>19.5, :year=>75, :origin=>1},
+{:name=>"pontiac catalina", :mpg=>16, :cylinders=>8, :displacement=>400, :horsepower=>170, :weight=>4668, :acceleration=>11.5, :year=>75, :origin=>1},
+{:name=>"chevrolet bel air", :mpg=>15, :cylinders=>8, :displacement=>350, :horsepower=>145, :weight=>4440, :acceleration=>14, :year=>75, :origin=>1},
+{:name=>"plymouth grand fury", :mpg=>16, :cylinders=>8, :displacement=>318, :horsepower=>150, :weight=>4498, :acceleration=>14.5, :year=>75, :origin=>1},
+{:name=>"ford ltd", :mpg=>14, :cylinders=>8, :displacement=>351, :horsepower=>148, :weight=>4657, :acceleration=>13.5, :year=>75, :origin=>1},
+{:name=>"buick century", :mpg=>17, :cylinders=>6, :displacement=>231, :horsepower=>110, :weight=>3907, :acceleration=>21, :year=>75, :origin=>1},
+{:name=>"chevroelt chevelle malibu", :mpg=>16, :cylinders=>6, :displacement=>250, :horsepower=>105, :weight=>3897, :acceleration=>18.5, :year=>75, :origin=>1},
+{:name=>"amc matador", :mpg=>15, :cylinders=>6, :displacement=>258, :horsepower=>110, :weight=>3730, :acceleration=>19, :year=>75, :origin=>1},
+{:name=>"plymouth fury", :mpg=>18, :cylinders=>6, :displacement=>225, :horsepower=>95, :weight=>3785, :acceleration=>19, :year=>75, :origin=>1},
+{:name=>"buick skyhawk", :mpg=>21, :cylinders=>6, :displacement=>231, :horsepower=>110, :weight=>3039, :acceleration=>15, :year=>75, :origin=>1},
+{:name=>"chevrolet monza 2+2", :mpg=>20, :cylinders=>8, :displacement=>262, :horsepower=>110, :weight=>3221, :acceleration=>13.5, :year=>75, :origin=>1},
+{:name=>"ford mustang ii", :mpg=>13, :cylinders=>8, :displacement=>302, :horsepower=>129, :weight=>3169, :acceleration=>12, :year=>75, :origin=>1},
+{:name=>"toyota corolla", :mpg=>29, :cylinders=>4, :displacement=>97, :horsepower=>75, :weight=>2171, :acceleration=>16, :year=>75, :origin=>3},
+{:name=>"ford pinto", :mpg=>23, :cylinders=>4, :displacement=>140, :horsepower=>83, :weight=>2639, :acceleration=>17, :year=>75, :origin=>1},
+{:name=>"amc gremlin", :mpg=>20, :cylinders=>6, :displacement=>232, :horsepower=>100, :weight=>2914, :acceleration=>16, :year=>75, :origin=>1},
+{:name=>"pontiac astro", :mpg=>23, :cylinders=>4, :displacement=>140, :horsepower=>78, :weight=>2592, :acceleration=>18.5, :year=>75, :origin=>1},
+{:name=>"toyota corona", :mpg=>24, :cylinders=>4, :displacement=>134, :horsepower=>96, :weight=>2702, :acceleration=>13.5, :year=>75, :origin=>3},
+{:name=>"volkswagen dasher", :mpg=>25, :cylinders=>4, :displacement=>90, :horsepower=>71, :weight=>2223, :acceleration=>16.5, :year=>75, :origin=>2},
+{:name=>"datsun 710", :mpg=>24, :cylinders=>4, :displacement=>119, :horsepower=>97, :weight=>2545, :acceleration=>17, :year=>75, :origin=>3},
+{:name=>"ford pinto", :mpg=>18, :cylinders=>6, :displacement=>171, :horsepower=>97, :weight=>2984, :acceleration=>14.5, :year=>75, :origin=>1},
+{:name=>"volkswagen rabbit", :mpg=>29, :cylinders=>4, :displacement=>90, :horsepower=>70, :weight=>1937, :acceleration=>14, :year=>75, :origin=>2},
+{:name=>"amc pacer", :mpg=>19, :cylinders=>6, :displacement=>232, :horsepower=>90, :weight=>3211, :acceleration=>17, :year=>75, :origin=>1},
+{:name=>"audi 100ls", :mpg=>23, :cylinders=>4, :displacement=>115, :horsepower=>95, :weight=>2694, :acceleration=>15, :year=>75, :origin=>2},
+{:name=>"peugeot 504", :mpg=>23, :cylinders=>4, :displacement=>120, :horsepower=>88, :weight=>2957, :acceleration=>17, :year=>75, :origin=>2},
+{:name=>"volvo 244dl", :mpg=>22, :cylinders=>4, :displacement=>121, :horsepower=>98, :weight=>2945, :acceleration=>14.5, :year=>75, :origin=>2},
+{:name=>"saab 99le", :mpg=>25, :cylinders=>4, :displacement=>121, :horsepower=>115, :weight=>2671, :acceleration=>13.5, :year=>75, :origin=>2},
+{:name=>"honda civic cvcc", :mpg=>33, :cylinders=>4, :displacement=>91, :horsepower=>53, :weight=>1795, :acceleration=>17.5, :year=>75, :origin=>3},
+{:name=>"fiat 131", :mpg=>28, :cylinders=>4, :displacement=>107, :horsepower=>86, :weight=>2464, :acceleration=>15.5, :year=>76, :origin=>2},
+{:name=>"opel 1900", :mpg=>25, :cylinders=>4, :displacement=>116, :horsepower=>81, :weight=>2220, :acceleration=>16.9, :year=>76, :origin=>2},
+{:name=>"capri ii", :mpg=>25, :cylinders=>4, :displacement=>140, :horsepower=>92, :weight=>2572, :acceleration=>14.9, :year=>76, :origin=>1},
+{:name=>"dodge colt", :mpg=>26, :cylinders=>4, :displacement=>98, :horsepower=>79, :weight=>2255, :acceleration=>17.7, :year=>76, :origin=>1},
+{:name=>"renault 12tl", :mpg=>27, :cylinders=>4, :displacement=>101, :horsepower=>83, :weight=>2202, :acceleration=>15.3, :year=>76, :origin=>2},
+{:name=>"chevrolet chevelle malibu classic", :mpg=>17.5, :cylinders=>8, :displacement=>305, :horsepower=>140, :weight=>4215, :acceleration=>13, :year=>76, :origin=>1},
+{:name=>"dodge coronet brougham", :mpg=>16, :cylinders=>8, :displacement=>318, :horsepower=>150, :weight=>4190, :acceleration=>13, :year=>76, :origin=>1},
+{:name=>"amc matador", :mpg=>15.5, :cylinders=>8, :displacement=>304, :horsepower=>120, :weight=>3962, :acceleration=>13.9, :year=>76, :origin=>1},
+{:name=>"ford gran torino", :mpg=>14.5, :cylinders=>8, :displacement=>351, :horsepower=>152, :weight=>4215, :acceleration=>12.8, :year=>76, :origin=>1},
+{:name=>"plymouth valiant", :mpg=>22, :cylinders=>6, :displacement=>225, :horsepower=>100, :weight=>3233, :acceleration=>15.4, :year=>76, :origin=>1},
+{:name=>"chevrolet nova", :mpg=>22, :cylinders=>6, :displacement=>250, :horsepower=>105, :weight=>3353, :acceleration=>14.5, :year=>76, :origin=>1},
+{:name=>"ford maverick", :mpg=>24, :cylinders=>6, :displacement=>200, :horsepower=>81, :weight=>3012, :acceleration=>17.6, :year=>76, :origin=>1},
+{:name=>"amc hornet", :mpg=>22.5, :cylinders=>6, :displacement=>232, :horsepower=>90, :weight=>3085, :acceleration=>17.6, :year=>76, :origin=>1},
+{:name=>"chevrolet chevette", :mpg=>29, :cylinders=>4, :displacement=>85, :horsepower=>52, :weight=>2035, :acceleration=>22.2, :year=>76, :origin=>1},
+{:name=>"chevrolet woody", :mpg=>24.5, :cylinders=>4, :displacement=>98, :horsepower=>60, :weight=>2164, :acceleration=>22.1, :year=>76, :origin=>1},
+{:name=>"vw rabbit", :mpg=>29, :cylinders=>4, :displacement=>90, :horsepower=>70, :weight=>1937, :acceleration=>14.2, :year=>76, :origin=>2},
+{:name=>"honda civic", :mpg=>33, :cylinders=>4, :displacement=>91, :horsepower=>53, :weight=>1795, :acceleration=>17.4, :year=>76, :origin=>3},
+{:name=>"dodge aspen se", :mpg=>20, :cylinders=>6, :displacement=>225, :horsepower=>100, :weight=>3651, :acceleration=>17.7, :year=>76, :origin=>1},
+{:name=>"ford granada ghia", :mpg=>18, :cylinders=>6, :displacement=>250, :horsepower=>78, :weight=>3574, :acceleration=>21, :year=>76, :origin=>1},
+{:name=>"pontiac ventura sj", :mpg=>18.5, :cylinders=>6, :displacement=>250, :horsepower=>110, :weight=>3645, :acceleration=>16.2, :year=>76, :origin=>1},
+{:name=>"amc pacer d/l", :mpg=>17.5, :cylinders=>6, :displacement=>258, :horsepower=>95, :weight=>3193, :acceleration=>17.8, :year=>76, :origin=>1},
+{:name=>"volkswagen rabbit", :mpg=>29.5, :cylinders=>4, :displacement=>97, :horsepower=>71, :weight=>1825, :acceleration=>12.2, :year=>76, :origin=>2},
+{:name=>"datsun b-210", :mpg=>32, :cylinders=>4, :displacement=>85, :horsepower=>70, :weight=>1990, :acceleration=>17, :year=>76, :origin=>3},
+{:name=>"toyota corolla", :mpg=>28, :cylinders=>4, :displacement=>97, :horsepower=>75, :weight=>2155, :acceleration=>16.4, :year=>76, :origin=>3},
+{:name=>"ford pinto", :mpg=>26.5, :cylinders=>4, :displacement=>140, :horsepower=>72, :weight=>2565, :acceleration=>13.6, :year=>76, :origin=>1},
+{:name=>"volvo 245", :mpg=>20, :cylinders=>4, :displacement=>130, :horsepower=>102, :weight=>3150, :acceleration=>15.7, :year=>76, :origin=>2},
+{:name=>"plymouth volare premier v8", :mpg=>13, :cylinders=>8, :displacement=>318, :horsepower=>150, :weight=>3940, :acceleration=>13.2, :year=>76, :origin=>1},
+{:name=>"peugeot 504", :mpg=>19, :cylinders=>4, :displacement=>120, :horsepower=>88, :weight=>3270, :acceleration=>21.9, :year=>76, :origin=>2},
+{:name=>"toyota mark ii", :mpg=>19, :cylinders=>6, :displacement=>156, :horsepower=>108, :weight=>2930, :acceleration=>15.5, :year=>76, :origin=>3},
+{:name=>"mercedes-benz 280s", :mpg=>16.5, :cylinders=>6, :displacement=>168, :horsepower=>120, :weight=>3820, :acceleration=>16.7, :year=>76, :origin=>2},
+{:name=>"cadillac seville", :mpg=>16.5, :cylinders=>8, :displacement=>350, :horsepower=>180, :weight=>4380, :acceleration=>12.1, :year=>76, :origin=>1},
+{:name=>"chevy c10", :mpg=>13, :cylinders=>8, :displacement=>350, :horsepower=>145, :weight=>4055, :acceleration=>12, :year=>76, :origin=>1},
+{:name=>"ford f108", :mpg=>13, :cylinders=>8, :displacement=>302, :horsepower=>130, :weight=>3870, :acceleration=>15, :year=>76, :origin=>1},
+{:name=>"dodge d100", :mpg=>13, :cylinders=>8, :displacement=>318, :horsepower=>150, :weight=>3755, :acceleration=>14, :year=>76, :origin=>1},
+{:name=>"honda accord cvcc", :mpg=>31.5, :cylinders=>4, :displacement=>98, :horsepower=>68, :weight=>2045, :acceleration=>18.5, :year=>77, :origin=>3},
+{:name=>"buick opel isuzu deluxe", :mpg=>30, :cylinders=>4, :displacement=>111, :horsepower=>80, :weight=>2155, :acceleration=>14.8, :year=>77, :origin=>1},
+{:name=>"renault 5 gtl", :mpg=>36, :cylinders=>4, :displacement=>79, :horsepower=>58, :weight=>1825, :acceleration=>18.6, :year=>77, :origin=>2},
+{:name=>"plymouth arrow gs", :mpg=>25.5, :cylinders=>4, :displacement=>122, :horsepower=>96, :weight=>2300, :acceleration=>15.5, :year=>77, :origin=>1},
+{:name=>"datsun f-10 hatchback", :mpg=>33.5, :cylinders=>4, :displacement=>85, :horsepower=>70, :weight=>1945, :acceleration=>16.8, :year=>77, :origin=>3},
+{:name=>"chevrolet caprice classic", :mpg=>17.5, :cylinders=>8, :displacement=>305, :horsepower=>145, :weight=>3880, :acceleration=>12.5, :year=>77, :origin=>1},
+{:name=>"oldsmobile cutlass supreme", :mpg=>17, :cylinders=>8, :displacement=>260, :horsepower=>110, :weight=>4060, :acceleration=>19, :year=>77, :origin=>1},
+{:name=>"dodge monaco brougham", :mpg=>15.5, :cylinders=>8, :displacement=>318, :horsepower=>145, :weight=>4140, :acceleration=>13.7, :year=>77, :origin=>1},
+{:name=>"mercury cougar brougham", :mpg=>15, :cylinders=>8, :displacement=>302, :horsepower=>130, :weight=>4295, :acceleration=>14.9, :year=>77, :origin=>1},
+{:name=>"chevrolet concours", :mpg=>17.5, :cylinders=>6, :displacement=>250, :horsepower=>110, :weight=>3520, :acceleration=>16.4, :year=>77, :origin=>1},
+{:name=>"buick skylark", :mpg=>20.5, :cylinders=>6, :displacement=>231, :horsepower=>105, :weight=>3425, :acceleration=>16.9, :year=>77, :origin=>1},
+{:name=>"plymouth volare custom", :mpg=>19, :cylinders=>6, :displacement=>225, :horsepower=>100, :weight=>3630, :acceleration=>17.7, :year=>77, :origin=>1},
+{:name=>"ford granada", :mpg=>18.5, :cylinders=>6, :displacement=>250, :horsepower=>98, :weight=>3525, :acceleration=>19, :year=>77, :origin=>1},
+{:name=>"pontiac grand prix lj", :mpg=>16, :cylinders=>8, :displacement=>400, :horsepower=>180, :weight=>4220, :acceleration=>11.1, :year=>77, :origin=>1},
+{:name=>"chevrolet monte carlo landau", :mpg=>15.5, :cylinders=>8, :displacement=>350, :horsepower=>170, :weight=>4165, :acceleration=>11.4, :year=>77, :origin=>1},
+{:name=>"chrysler cordoba", :mpg=>15.5, :cylinders=>8, :displacement=>400, :horsepower=>190, :weight=>4325, :acceleration=>12.2, :year=>77, :origin=>1},
+{:name=>"ford thunderbird", :mpg=>16, :cylinders=>8, :displacement=>351, :horsepower=>149, :weight=>4335, :acceleration=>14.5, :year=>77, :origin=>1},
+{:name=>"volkswagen rabbit custom", :mpg=>29, :cylinders=>4, :displacement=>97, :horsepower=>78, :weight=>1940, :acceleration=>14.5, :year=>77, :origin=>2},
+{:name=>"pontiac sunbird coupe", :mpg=>24.5, :cylinders=>4, :displacement=>151, :horsepower=>88, :weight=>2740, :acceleration=>16, :year=>77, :origin=>1},
+{:name=>"toyota corolla liftback", :mpg=>26, :cylinders=>4, :displacement=>97, :horsepower=>75, :weight=>2265, :acceleration=>18.2, :year=>77, :origin=>3},
+{:name=>"ford mustang ii 2+2", :mpg=>25.5, :cylinders=>4, :displacement=>140, :horsepower=>89, :weight=>2755, :acceleration=>15.8, :year=>77, :origin=>1},
+{:name=>"chevrolet chevette", :mpg=>30.5, :cylinders=>4, :displacement=>98, :horsepower=>63, :weight=>2051, :acceleration=>17, :year=>77, :origin=>1},
+{:name=>"dodge colt m/m", :mpg=>33.5, :cylinders=>4, :displacement=>98, :horsepower=>83, :weight=>2075, :acceleration=>15.9, :year=>77, :origin=>1},
+{:name=>"subaru dl", :mpg=>30, :cylinders=>4, :displacement=>97, :horsepower=>67, :weight=>1985, :acceleration=>16.4, :year=>77, :origin=>3},
+{:name=>"volkswagen dasher", :mpg=>30.5, :cylinders=>4, :displacement=>97, :horsepower=>78, :weight=>2190, :acceleration=>14.1, :year=>77, :origin=>2},
+{:name=>"datsun 810", :mpg=>22, :cylinders=>6, :displacement=>146, :horsepower=>97, :weight=>2815, :acceleration=>14.5, :year=>77, :origin=>3},
+{:name=>"bmw 320i", :mpg=>21.5, :cylinders=>4, :displacement=>121, :horsepower=>110, :weight=>2600, :acceleration=>12.8, :year=>77, :origin=>2},
+{:name=>"mazda rx-4", :mpg=>21.5, :cylinders=>3, :displacement=>80, :horsepower=>110, :weight=>2720, :acceleration=>13.5, :year=>77, :origin=>3},
+{:name=>"volkswagen rabbit custom diesel", :mpg=>43.1, :cylinders=>4, :displacement=>90, :horsepower=>48, :weight=>1985, :acceleration=>21.5, :year=>78, :origin=>2},
+{:name=>"ford fiesta", :mpg=>36.1, :cylinders=>4, :displacement=>98, :horsepower=>66, :weight=>1800, :acceleration=>14.4, :year=>78, :origin=>1},
+{:name=>"mazda glc deluxe", :mpg=>32.8, :cylinders=>4, :displacement=>78, :horsepower=>52, :weight=>1985, :acceleration=>19.4, :year=>78, :origin=>3},
+{:name=>"datsun b210 gx", :mpg=>39.4, :cylinders=>4, :displacement=>85, :horsepower=>70, :weight=>2070, :acceleration=>18.6, :year=>78, :origin=>3},
+{:name=>"honda civic cvcc", :mpg=>36.1, :cylinders=>4, :displacement=>91, :horsepower=>60, :weight=>1800, :acceleration=>16.4, :year=>78, :origin=>3},
+{:name=>"oldsmobile cutlass salon brougham", :mpg=>19.9, :cylinders=>8, :displacement=>260, :horsepower=>110, :weight=>3365, :acceleration=>15.5, :year=>78, :origin=>1},
+{:name=>"dodge diplomat", :mpg=>19.4, :cylinders=>8, :displacement=>318, :horsepower=>140, :weight=>3735, :acceleration=>13.2, :year=>78, :origin=>1},
+{:name=>"mercury monarch ghia", :mpg=>20.2, :cylinders=>8, :displacement=>302, :horsepower=>139, :weight=>3570, :acceleration=>12.8, :year=>78, :origin=>1},
+{:name=>"pontiac phoenix lj", :mpg=>19.2, :cylinders=>6, :displacement=>231, :horsepower=>105, :weight=>3535, :acceleration=>19.2, :year=>78, :origin=>1},
+{:name=>"chevrolet malibu", :mpg=>20.5, :cylinders=>6, :displacement=>200, :horsepower=>95, :weight=>3155, :acceleration=>18.2, :year=>78, :origin=>1},
+{:name=>"ford fairmont (auto)", :mpg=>20.2, :cylinders=>6, :displacement=>200, :horsepower=>85, :weight=>2965, :acceleration=>15.8, :year=>78, :origin=>1},
+{:name=>"ford fairmont (man)", :mpg=>25.1, :cylinders=>4, :displacement=>140, :horsepower=>88, :weight=>2720, :acceleration=>15.4, :year=>78, :origin=>1},
+{:name=>"plymouth volare", :mpg=>20.5, :cylinders=>6, :displacement=>225, :horsepower=>100, :weight=>3430, :acceleration=>17.2, :year=>78, :origin=>1},
+{:name=>"amc concord", :mpg=>19.4, :cylinders=>6, :displacement=>232, :horsepower=>90, :weight=>3210, :acceleration=>17.2, :year=>78, :origin=>1},
+{:name=>"buick century special", :mpg=>20.6, :cylinders=>6, :displacement=>231, :horsepower=>105, :weight=>3380, :acceleration=>15.8, :year=>78, :origin=>1},
+{:name=>"mercury zephyr", :mpg=>20.8, :cylinders=>6, :displacement=>200, :horsepower=>85, :weight=>3070, :acceleration=>16.7, :year=>78, :origin=>1},
+{:name=>"dodge aspen", :mpg=>18.6, :cylinders=>6, :displacement=>225, :horsepower=>110, :weight=>3620, :acceleration=>18.7, :year=>78, :origin=>1},
+{:name=>"amc concord d/l", :mpg=>18.1, :cylinders=>6, :displacement=>258, :horsepower=>120, :weight=>3410, :acceleration=>15.1, :year=>78, :origin=>1},
+{:name=>"chevrolet monte carlo landau", :mpg=>19.2, :cylinders=>8, :displacement=>305, :horsepower=>145, :weight=>3425, :acceleration=>13.2, :year=>78, :origin=>1},
+{:name=>"buick regal sport coupe (turbo)", :mpg=>17.7, :cylinders=>6, :displacement=>231, :horsepower=>165, :weight=>3445, :acceleration=>13.4, :year=>78, :origin=>1},
+{:name=>"ford futura", :mpg=>18.1, :cylinders=>8, :displacement=>302, :horsepower=>139, :weight=>3205, :acceleration=>11.2, :year=>78, :origin=>1},
+{:name=>"dodge magnum xe", :mpg=>17.5, :cylinders=>8, :displacement=>318, :horsepower=>140, :weight=>4080, :acceleration=>13.7, :year=>78, :origin=>1},
+{:name=>"chevrolet chevette", :mpg=>30, :cylinders=>4, :displacement=>98, :horsepower=>68, :weight=>2155, :acceleration=>16.5, :year=>78, :origin=>1},
+{:name=>"toyota corona", :mpg=>27.5, :cylinders=>4, :displacement=>134, :horsepower=>95, :weight=>2560, :acceleration=>14.2, :year=>78, :origin=>3},
+{:name=>"datsun 510", :mpg=>27.2, :cylinders=>4, :displacement=>119, :horsepower=>97, :weight=>2300, :acceleration=>14.7, :year=>78, :origin=>3},
+{:name=>"dodge omni", :mpg=>30.9, :cylinders=>4, :displacement=>105, :horsepower=>75, :weight=>2230, :acceleration=>14.5, :year=>78, :origin=>1},
+{:name=>"toyota celica gt liftback", :mpg=>21.1, :cylinders=>4, :displacement=>134, :horsepower=>95, :weight=>2515, :acceleration=>14.8, :year=>78, :origin=>3},
+{:name=>"plymouth sapporo", :mpg=>23.2, :cylinders=>4, :displacement=>156, :horsepower=>105, :weight=>2745, :acceleration=>16.7, :year=>78, :origin=>1},
+{:name=>"oldsmobile starfire sx", :mpg=>23.8, :cylinders=>4, :displacement=>151, :horsepower=>85, :weight=>2855, :acceleration=>17.6, :year=>78, :origin=>1},
+{:name=>"datsun 200-sx", :mpg=>23.9, :cylinders=>4, :displacement=>119, :horsepower=>97, :weight=>2405, :acceleration=>14.9, :year=>78, :origin=>3},
+{:name=>"audi 5000", :mpg=>20.3, :cylinders=>5, :displacement=>131, :horsepower=>103, :weight=>2830, :acceleration=>15.9, :year=>78, :origin=>2},
+{:name=>"volvo 264gl", :mpg=>17, :cylinders=>6, :displacement=>163, :horsepower=>125, :weight=>3140, :acceleration=>13.6, :year=>78, :origin=>2},
+{:name=>"saab 99gle", :mpg=>21.6, :cylinders=>4, :displacement=>121, :horsepower=>115, :weight=>2795, :acceleration=>15.7, :year=>78, :origin=>2},
+{:name=>"peugeot 604sl", :mpg=>16.2, :cylinders=>6, :displacement=>163, :horsepower=>133, :weight=>3410, :acceleration=>15.8, :year=>78, :origin=>2},
+{:name=>"volkswagen scirocco", :mpg=>31.5, :cylinders=>4, :displacement=>89, :horsepower=>71, :weight=>1990, :acceleration=>14.9, :year=>78, :origin=>2},
+{:name=>"honda accord lx", :mpg=>29.5, :cylinders=>4, :displacement=>98, :horsepower=>68, :weight=>2135, :acceleration=>16.6, :year=>78, :origin=>3},
+{:name=>"pontiac lemans v6", :mpg=>21.5, :cylinders=>6, :displacement=>231, :horsepower=>115, :weight=>3245, :acceleration=>15.4, :year=>79, :origin=>1},
+{:name=>"mercury zephyr 6", :mpg=>19.8, :cylinders=>6, :displacement=>200, :horsepower=>85, :weight=>2990, :acceleration=>18.2, :year=>79, :origin=>1},
+{:name=>"ford fairmont 4", :mpg=>22.3, :cylinders=>4, :displacement=>140, :horsepower=>88, :weight=>2890, :acceleration=>17.3, :year=>79, :origin=>1},
+{:name=>"amc concord dl 6", :mpg=>20.2, :cylinders=>6, :displacement=>232, :horsepower=>90, :weight=>3265, :acceleration=>18.2, :year=>79, :origin=>1},
+{:name=>"dodge aspen 6", :mpg=>20.6, :cylinders=>6, :displacement=>225, :horsepower=>110, :weight=>3360, :acceleration=>16.6, :year=>79, :origin=>1},
+{:name=>"chevrolet caprice classic", :mpg=>17, :cylinders=>8, :displacement=>305, :horsepower=>130, :weight=>3840, :acceleration=>15.4, :year=>79, :origin=>1},
+{:name=>"ford ltd landau", :mpg=>17.6, :cylinders=>8, :displacement=>302, :horsepower=>129, :weight=>3725, :acceleration=>13.4, :year=>79, :origin=>1},
+{:name=>"mercury grand marquis", :mpg=>16.5, :cylinders=>8, :displacement=>351, :horsepower=>138, :weight=>3955, :acceleration=>13.2, :year=>79, :origin=>1},
+{:name=>"dodge st. regis", :mpg=>18.2, :cylinders=>8, :displacement=>318, :horsepower=>135, :weight=>3830, :acceleration=>15.2, :year=>79, :origin=>1},
+{:name=>"buick estate wagon (sw)", :mpg=>16.9, :cylinders=>8, :displacement=>350, :horsepower=>155, :weight=>4360, :acceleration=>14.9, :year=>79, :origin=>1},
+{:name=>"ford country squire (sw)", :mpg=>15.5, :cylinders=>8, :displacement=>351, :horsepower=>142, :weight=>4054, :acceleration=>14.3, :year=>79, :origin=>1},
+{:name=>"chevrolet malibu classic (sw)", :mpg=>19.2, :cylinders=>8, :displacement=>267, :horsepower=>125, :weight=>3605, :acceleration=>15, :year=>79, :origin=>1},
+{:name=>"chrysler lebaron town @ country (sw)", :mpg=>18.5, :cylinders=>8, :displacement=>360, :horsepower=>150, :weight=>3940, :acceleration=>13, :year=>79, :origin=>1},
+{:name=>"vw rabbit custom", :mpg=>31.9, :cylinders=>4, :displacement=>89, :horsepower=>71, :weight=>1925, :acceleration=>14, :year=>79, :origin=>2},
+{:name=>"maxda glc deluxe", :mpg=>34.1, :cylinders=>4, :displacement=>86, :horsepower=>65, :weight=>1975, :acceleration=>15.2, :year=>79, :origin=>3},
+{:name=>"dodge colt hatchback custom", :mpg=>35.7, :cylinders=>4, :displacement=>98, :horsepower=>80, :weight=>1915, :acceleration=>14.4, :year=>79, :origin=>1},
+{:name=>"amc spirit dl", :mpg=>27.4, :cylinders=>4, :displacement=>121, :horsepower=>80, :weight=>2670, :acceleration=>15, :year=>79, :origin=>1},
+{:name=>"mercedes benz 300d", :mpg=>25.4, :cylinders=>5, :displacement=>183, :horsepower=>77, :weight=>3530, :acceleration=>20.1, :year=>79, :origin=>2},
+{:name=>"cadillac eldorado", :mpg=>23, :cylinders=>8, :displacement=>350, :horsepower=>125, :weight=>3900, :acceleration=>17.4, :year=>79, :origin=>1},
+{:name=>"peugeot 504", :mpg=>27.2, :cylinders=>4, :displacement=>141, :horsepower=>71, :weight=>3190, :acceleration=>24.8, :year=>79, :origin=>2},
+{:name=>"oldsmobile cutlass salon brougham", :mpg=>23.9, :cylinders=>8, :displacement=>260, :horsepower=>90, :weight=>3420, :acceleration=>22.2, :year=>79, :origin=>1},
+{:name=>"plymouth horizon", :mpg=>34.2, :cylinders=>4, :displacement=>105, :horsepower=>70, :weight=>2200, :acceleration=>13.2, :year=>79, :origin=>1},
+{:name=>"plymouth horizon tc3", :mpg=>34.5, :cylinders=>4, :displacement=>105, :horsepower=>70, :weight=>2150, :acceleration=>14.9, :year=>79, :origin=>1},
+{:name=>"datsun 210", :mpg=>31.8, :cylinders=>4, :displacement=>85, :horsepower=>65, :weight=>2020, :acceleration=>19.2, :year=>79, :origin=>3},
+{:name=>"fiat strada custom", :mpg=>37.3, :cylinders=>4, :displacement=>91, :horsepower=>69, :weight=>2130, :acceleration=>14.7, :year=>79, :origin=>2},
+{:name=>"buick skylark limited", :mpg=>28.4, :cylinders=>4, :displacement=>151, :horsepower=>90, :weight=>2670, :acceleration=>16, :year=>79, :origin=>1},
+{:name=>"chevrolet citation", :mpg=>28.8, :cylinders=>6, :displacement=>173, :horsepower=>115, :weight=>2595, :acceleration=>11.3, :year=>79, :origin=>1},
+{:name=>"oldsmobile omega brougham", :mpg=>26.8, :cylinders=>6, :displacement=>173, :horsepower=>115, :weight=>2700, :acceleration=>12.9, :year=>79, :origin=>1},
+{:name=>"pontiac phoenix", :mpg=>33.5, :cylinders=>4, :displacement=>151, :horsepower=>90, :weight=>2556, :acceleration=>13.2, :year=>79, :origin=>1},
+{:name=>"vw rabbit", :mpg=>41.5, :cylinders=>4, :displacement=>98, :horsepower=>76, :weight=>2144, :acceleration=>14.7, :year=>80, :origin=>2},
+{:name=>"toyota corolla tercel", :mpg=>38.1, :cylinders=>4, :displacement=>89, :horsepower=>60, :weight=>1968, :acceleration=>18.8, :year=>80, :origin=>3},
+{:name=>"chevrolet chevette", :mpg=>32.1, :cylinders=>4, :displacement=>98, :horsepower=>70, :weight=>2120, :acceleration=>15.5, :year=>80, :origin=>1},
+{:name=>"datsun 310", :mpg=>37.2, :cylinders=>4, :displacement=>86, :horsepower=>65, :weight=>2019, :acceleration=>16.4, :year=>80, :origin=>3},
+{:name=>"chevrolet citation", :mpg=>28, :cylinders=>4, :displacement=>151, :horsepower=>90, :weight=>2678, :acceleration=>16.5, :year=>80, :origin=>1},
+{:name=>"ford fairmont", :mpg=>26.4, :cylinders=>4, :displacement=>140, :horsepower=>88, :weight=>2870, :acceleration=>18.1, :year=>80, :origin=>1},
+{:name=>"amc concord", :mpg=>24.3, :cylinders=>4, :displacement=>151, :horsepower=>90, :weight=>3003, :acceleration=>20.1, :year=>80, :origin=>1},
+{:name=>"dodge aspen", :mpg=>19.1, :cylinders=>6, :displacement=>225, :horsepower=>90, :weight=>3381, :acceleration=>18.7, :year=>80, :origin=>1},
+{:name=>"audi 4000", :mpg=>34.3, :cylinders=>4, :displacement=>97, :horsepower=>78, :weight=>2188, :acceleration=>15.8, :year=>80, :origin=>2},
+{:name=>"toyota corona liftback", :mpg=>29.8, :cylinders=>4, :displacement=>134, :horsepower=>90, :weight=>2711, :acceleration=>15.5, :year=>80, :origin=>3},
+{:name=>"mazda 626", :mpg=>31.3, :cylinders=>4, :displacement=>120, :horsepower=>75, :weight=>2542, :acceleration=>17.5, :year=>80, :origin=>3},
+{:name=>"datsun 510 hatchback", :mpg=>37, :cylinders=>4, :displacement=>119, :horsepower=>92, :weight=>2434, :acceleration=>15, :year=>80, :origin=>3},
+{:name=>"toyota corolla", :mpg=>32.2, :cylinders=>4, :displacement=>108, :horsepower=>75, :weight=>2265, :acceleration=>15.2, :year=>80, :origin=>3},
+{:name=>"mazda glc", :mpg=>46.6, :cylinders=>4, :displacement=>86, :horsepower=>65, :weight=>2110, :acceleration=>17.9, :year=>80, :origin=>3},
+{:name=>"dodge colt", :mpg=>27.9, :cylinders=>4, :displacement=>156, :horsepower=>105, :weight=>2800, :acceleration=>14.4, :year=>80, :origin=>1},
+{:name=>"datsun 210", :mpg=>40.8, :cylinders=>4, :displacement=>85, :horsepower=>65, :weight=>2110, :acceleration=>19.2, :year=>80, :origin=>3},
+{:name=>"vw rabbit c (diesel)", :mpg=>44.3, :cylinders=>4, :displacement=>90, :horsepower=>48, :weight=>2085, :acceleration=>21.7, :year=>80, :origin=>2},
+{:name=>"vw dasher (diesel)", :mpg=>43.4, :cylinders=>4, :displacement=>90, :horsepower=>48, :weight=>2335, :acceleration=>23.7, :year=>80, :origin=>2},
+{:name=>"audi 5000s (diesel)", :mpg=>36.4, :cylinders=>5, :displacement=>121, :horsepower=>67, :weight=>2950, :acceleration=>19.9, :year=>80, :origin=>2},
+{:name=>"mercedes-benz 240d", :mpg=>30, :cylinders=>4, :displacement=>146, :horsepower=>67, :weight=>3250, :acceleration=>21.8, :year=>80, :origin=>2},
+{:name=>"honda civic 1500 gl", :mpg=>44.6, :cylinders=>4, :displacement=>91, :horsepower=>67, :weight=>1850, :acceleration=>13.8, :year=>80, :origin=>3},
+{:name=>"renault lecar deluxe", :mpg=>40.9, :cylinders=>4, :displacement=>85, :horsepower=>nil, :weight=>1835, :acceleration=>17.3, :year=>80, :origin=>2},
+{:name=>"subaru dl", :mpg=>33.8, :cylinders=>4, :displacement=>97, :horsepower=>67, :weight=>2145, :acceleration=>18, :year=>80, :origin=>3},
+{:name=>"vokswagen rabbit", :mpg=>29.8, :cylinders=>4, :displacement=>89, :horsepower=>62, :weight=>1845, :acceleration=>15.3, :year=>80, :origin=>2},
+{:name=>"datsun 280-zx", :mpg=>32.7, :cylinders=>6, :displacement=>168, :horsepower=>132, :weight=>2910, :acceleration=>11.4, :year=>80, :origin=>3},
+{:name=>"mazda rx-7 gs", :mpg=>23.7, :cylinders=>3, :displacement=>70, :horsepower=>100, :weight=>2420, :acceleration=>12.5, :year=>80, :origin=>3},
+{:name=>"triumph tr7 coupe", :mpg=>35, :cylinders=>4, :displacement=>122, :horsepower=>88, :weight=>2500, :acceleration=>15.1, :year=>80, :origin=>2},
+{:name=>"ford mustang cobra", :mpg=>23.6, :cylinders=>4, :displacement=>140, :horsepower=>nil, :weight=>2905, :acceleration=>14.3, :year=>80, :origin=>1},
+{:name=>"honda accord", :mpg=>32.4, :cylinders=>4, :displacement=>107, :horsepower=>72, :weight=>2290, :acceleration=>17, :year=>80, :origin=>3},
+{:name=>"plymouth reliant", :mpg=>27.2, :cylinders=>4, :displacement=>135, :horsepower=>84, :weight=>2490, :acceleration=>15.7, :year=>81, :origin=>1},
+{:name=>"buick skylark", :mpg=>26.6, :cylinders=>4, :displacement=>151, :horsepower=>84, :weight=>2635, :acceleration=>16.4, :year=>81, :origin=>1},
+{:name=>"dodge aries wagon (sw)", :mpg=>25.8, :cylinders=>4, :displacement=>156, :horsepower=>92, :weight=>2620, :acceleration=>14.4, :year=>81, :origin=>1},
+{:name=>"chevrolet citation", :mpg=>23.5, :cylinders=>6, :displacement=>173, :horsepower=>110, :weight=>2725, :acceleration=>12.6, :year=>81, :origin=>1},
+{:name=>"plymouth reliant", :mpg=>30, :cylinders=>4, :displacement=>135, :horsepower=>84, :weight=>2385, :acceleration=>12.9, :year=>81, :origin=>1},
+{:name=>"toyota starlet", :mpg=>39.1, :cylinders=>4, :displacement=>79, :horsepower=>58, :weight=>1755, :acceleration=>16.9, :year=>81, :origin=>3},
+{:name=>"plymouth champ", :mpg=>39, :cylinders=>4, :displacement=>86, :horsepower=>64, :weight=>1875, :acceleration=>16.4, :year=>81, :origin=>1},
+{:name=>"honda civic 1300", :mpg=>35.1, :cylinders=>4, :displacement=>81, :horsepower=>60, :weight=>1760, :acceleration=>16.1, :year=>81, :origin=>3},
+{:name=>"subaru", :mpg=>32.3, :cylinders=>4, :displacement=>97, :horsepower=>67, :weight=>2065, :acceleration=>17.8, :year=>81, :origin=>3},
+{:name=>"datsun 210 mpg", :mpg=>37, :cylinders=>4, :displacement=>85, :horsepower=>65, :weight=>1975, :acceleration=>19.4, :year=>81, :origin=>3},
+{:name=>"toyota tercel", :mpg=>37.7, :cylinders=>4, :displacement=>89, :horsepower=>62, :weight=>2050, :acceleration=>17.3, :year=>81, :origin=>3},
+{:name=>"mazda glc 4", :mpg=>34.1, :cylinders=>4, :displacement=>91, :horsepower=>68, :weight=>1985, :acceleration=>16, :year=>81, :origin=>3},
+{:name=>"plymouth horizon 4", :mpg=>34.7, :cylinders=>4, :displacement=>105, :horsepower=>63, :weight=>2215, :acceleration=>14.9, :year=>81, :origin=>1},
+{:name=>"ford escort 4w", :mpg=>34.4, :cylinders=>4, :displacement=>98, :horsepower=>65, :weight=>2045, :acceleration=>16.2, :year=>81, :origin=>1},
+{:name=>"ford escort 2h", :mpg=>29.9, :cylinders=>4, :displacement=>98, :horsepower=>65, :weight=>2380, :acceleration=>20.7, :year=>81, :origin=>1},
+{:name=>"volkswagen jetta", :mpg=>33, :cylinders=>4, :displacement=>105, :horsepower=>74, :weight=>2190, :acceleration=>14.2, :year=>81, :origin=>2},
+{:name=>"renault 18i", :mpg=>34.5, :cylinders=>4, :displacement=>100, :horsepower=>nil, :weight=>2320, :acceleration=>15.8, :year=>81, :origin=>2},
+{:name=>"honda prelude", :mpg=>33.7, :cylinders=>4, :displacement=>107, :horsepower=>75, :weight=>2210, :acceleration=>14.4, :year=>81, :origin=>3},
+{:name=>"toyota corolla", :mpg=>32.4, :cylinders=>4, :displacement=>108, :horsepower=>75, :weight=>2350, :acceleration=>16.8, :year=>81, :origin=>3},
+{:name=>"datsun 200sx", :mpg=>32.9, :cylinders=>4, :displacement=>119, :horsepower=>100, :weight=>2615, :acceleration=>14.8, :year=>81, :origin=>3},
+{:name=>"mazda 626", :mpg=>31.6, :cylinders=>4, :displacement=>120, :horsepower=>74, :weight=>2635, :acceleration=>18.3, :year=>81, :origin=>3},
+{:name=>"peugeot 505s turbo diesel", :mpg=>28.1, :cylinders=>4, :displacement=>141, :horsepower=>80, :weight=>3230, :acceleration=>20.4, :year=>81, :origin=>2},
+{:name=>"saab 900s", :mpg=>nil, :cylinders=>4, :displacement=>121, :horsepower=>110, :weight=>2800, :acceleration=>15.4, :year=>81, :origin=>2},
+{:name=>"volvo diesel", :mpg=>30.7, :cylinders=>6, :displacement=>145, :horsepower=>76, :weight=>3160, :acceleration=>19.6, :year=>81, :origin=>2},
+{:name=>"toyota cressida", :mpg=>25.4, :cylinders=>6, :displacement=>168, :horsepower=>116, :weight=>2900, :acceleration=>12.6, :year=>81, :origin=>3},
+{:name=>"datsun 810 maxima", :mpg=>24.2, :cylinders=>6, :displacement=>146, :horsepower=>120, :weight=>2930, :acceleration=>13.8, :year=>81, :origin=>3},
+{:name=>"buick century", :mpg=>22.4, :cylinders=>6, :displacement=>231, :horsepower=>110, :weight=>3415, :acceleration=>15.8, :year=>81, :origin=>1},
+{:name=>"oldsmobile cutlass ls", :mpg=>26.6, :cylinders=>8, :displacement=>350, :horsepower=>105, :weight=>3725, :acceleration=>19, :year=>81, :origin=>1},
+{:name=>"ford granada gl", :mpg=>20.2, :cylinders=>6, :displacement=>200, :horsepower=>88, :weight=>3060, :acceleration=>17.1, :year=>81, :origin=>1},
+{:name=>"chrysler lebaron salon", :mpg=>17.6, :cylinders=>6, :displacement=>225, :horsepower=>85, :weight=>3465, :acceleration=>16.6, :year=>81, :origin=>1},
+{:name=>"chevrolet cavalier", :mpg=>28, :cylinders=>4, :displacement=>112, :horsepower=>88, :weight=>2605, :acceleration=>19.6, :year=>82, :origin=>1},
+{:name=>"chevrolet cavalier wagon", :mpg=>27, :cylinders=>4, :displacement=>112, :horsepower=>88, :weight=>2640, :acceleration=>18.6, :year=>82, :origin=>1},
+{:name=>"chevrolet cavalier 2-door", :mpg=>34, :cylinders=>4, :displacement=>112, :horsepower=>88, :weight=>2395, :acceleration=>18, :year=>82, :origin=>1},
+{:name=>"pontiac j2000 se hatchback", :mpg=>31, :cylinders=>4, :displacement=>112, :horsepower=>85, :weight=>2575, :acceleration=>16.2, :year=>82, :origin=>1},
+{:name=>"dodge aries se", :mpg=>29, :cylinders=>4, :displacement=>135, :horsepower=>84, :weight=>2525, :acceleration=>16, :year=>82, :origin=>1},
+{:name=>"pontiac phoenix", :mpg=>27, :cylinders=>4, :displacement=>151, :horsepower=>90, :weight=>2735, :acceleration=>18, :year=>82, :origin=>1},
+{:name=>"ford fairmont futura", :mpg=>24, :cylinders=>4, :displacement=>140, :horsepower=>92, :weight=>2865, :acceleration=>16.4, :year=>82, :origin=>1},
+{:name=>"amc concord dl", :mpg=>23, :cylinders=>4, :displacement=>151, :horsepower=>nil, :weight=>3035, :acceleration=>20.5, :year=>82, :origin=>1},
+{:name=>"volkswagen rabbit l", :mpg=>36, :cylinders=>4, :displacement=>105, :horsepower=>74, :weight=>1980, :acceleration=>15.3, :year=>82, :origin=>2},
+{:name=>"mazda glc custom l", :mpg=>37, :cylinders=>4, :displacement=>91, :horsepower=>68, :weight=>2025, :acceleration=>18.2, :year=>82, :origin=>3},
+{:name=>"mazda glc custom", :mpg=>31, :cylinders=>4, :displacement=>91, :horsepower=>68, :weight=>1970, :acceleration=>17.6, :year=>82, :origin=>3},
+{:name=>"plymouth horizon miser", :mpg=>38, :cylinders=>4, :displacement=>105, :horsepower=>63, :weight=>2125, :acceleration=>14.7, :year=>82, :origin=>1},
+{:name=>"mercury lynx l", :mpg=>36, :cylinders=>4, :displacement=>98, :horsepower=>70, :weight=>2125, :acceleration=>17.3, :year=>82, :origin=>1},
+{:name=>"nissan stanza xe", :mpg=>36, :cylinders=>4, :displacement=>120, :horsepower=>88, :weight=>2160, :acceleration=>14.5, :year=>82, :origin=>3},
+{:name=>"honda accord", :mpg=>36, :cylinders=>4, :displacement=>107, :horsepower=>75, :weight=>2205, :acceleration=>14.5, :year=>82, :origin=>3},
+{:name=>"toyota corolla", :mpg=>34, :cylinders=>4, :displacement=>108, :horsepower=>70, :weight=>2245, :acceleration=>16.9, :year=>82, :origin=>3},
+{:name=>"honda civic", :mpg=>38, :cylinders=>4, :displacement=>91, :horsepower=>67, :weight=>1965, :acceleration=>15, :year=>82, :origin=>3},
+{:name=>"honda civic (auto)", :mpg=>32, :cylinders=>4, :displacement=>91, :horsepower=>67, :weight=>1965, :acceleration=>15.7, :year=>82, :origin=>3},
+{:name=>"datsun 310 gx", :mpg=>38, :cylinders=>4, :displacement=>91, :horsepower=>67, :weight=>1995, :acceleration=>16.2, :year=>82, :origin=>3},
+{:name=>"buick century limited", :mpg=>25, :cylinders=>6, :displacement=>181, :horsepower=>110, :weight=>2945, :acceleration=>16.4, :year=>82, :origin=>1},
+{:name=>"oldsmobile cutlass ciera (diesel)", :mpg=>38, :cylinders=>6, :displacement=>262, :horsepower=>85, :weight=>3015, :acceleration=>17, :year=>82, :origin=>1},
+{:name=>"chrysler lebaron medallion", :mpg=>26, :cylinders=>4, :displacement=>156, :horsepower=>92, :weight=>2585, :acceleration=>14.5, :year=>82, :origin=>1},
+{:name=>"ford granada l", :mpg=>22, :cylinders=>6, :displacement=>232, :horsepower=>112, :weight=>2835, :acceleration=>14.7, :year=>82, :origin=>1},
+{:name=>"toyota celica gt", :mpg=>32, :cylinders=>4, :displacement=>144, :horsepower=>96, :weight=>2665, :acceleration=>13.9, :year=>82, :origin=>3},
+{:name=>"dodge charger 2.2", :mpg=>36, :cylinders=>4, :displacement=>135, :horsepower=>84, :weight=>2370, :acceleration=>13, :year=>82, :origin=>1},
+{:name=>"chevrolet camaro", :mpg=>27, :cylinders=>4, :displacement=>151, :horsepower=>90, :weight=>2950, :acceleration=>17.3, :year=>82, :origin=>1},
+{:name=>"ford mustang gl", :mpg=>27, :cylinders=>4, :displacement=>140, :horsepower=>86, :weight=>2790, :acceleration=>15.6, :year=>82, :origin=>1},
+{:name=>"vw pickup", :mpg=>44, :cylinders=>4, :displacement=>97, :horsepower=>52, :weight=>2130, :acceleration=>24.6, :year=>82, :origin=>2},
+{:name=>"dodge rampage", :mpg=>32, :cylinders=>4, :displacement=>135, :horsepower=>84, :weight=>2295, :acceleration=>11.6, :year=>82, :origin=>1},
+{:name=>"ford ranger", :mpg=>28, :cylinders=>4, :displacement=>120, :horsepower=>79, :weight=>2625, :acceleration=>18.6, :year=>82, :origin=>1},
+{:name=>"chevy s-10", :mpg=>31, :cylinders=>4, :displacement=>119, :horsepower=>82, :weight=>2720, :acceleration=>19.4, :year=>82, :origin=>1}
+]
+
diff --git a/examples/4_pv_custom/crimea/crimea_data.rb b/examples/4_pv_custom/crimea/crimea_data.rb
new file mode 100644
index 0000000..c428e90
--- /dev/null
+++ b/examples/4_pv_custom/crimea/crimea_data.rb
@@ -0,0 +1,37 @@
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+require 'ostruct'
+
+$causes = ["wounds", "other", "disease"];
+
+$crimea = [
+  OpenStruct.new({ date: "4/1854", wounds: 0, other: 110, disease: 110 }),
+  OpenStruct.new({ date: "5/1854", wounds: 0, other: 95, disease: 105 }),
+  OpenStruct.new({ date: "6/1854", wounds: 0, other: 40, disease: 95 }),
+  OpenStruct.new({ date: "7/1854", wounds: 0, other: 140, disease: 520 }),
+  OpenStruct.new({ date: "8/1854", wounds: 20, other: 150, disease: 800 }),
+  OpenStruct.new({ date: "9/1854", wounds: 220, other: 230, disease: 740 }),
+  OpenStruct.new({ date: "10/1854", wounds: 305, other: 310, disease: 600 }),
+  OpenStruct.new({ date: "11/1854", wounds: 480, other: 290, disease: 820 }),
+  OpenStruct.new({ date: "12/1854", wounds: 295, other: 310, disease: 1100 }),
+  OpenStruct.new({ date: "1/1855", wounds: 230, other: 460, disease: 1440 }),
+  OpenStruct.new({ date: "2/1855", wounds: 180, other: 520, disease: 1270 }),
+  OpenStruct.new({ date: "3/1855", wounds: 155, other: 350, disease: 935 }),
+  OpenStruct.new({ date: "4/1855", wounds: 195, other: 195, disease: 560 }),
+  OpenStruct.new({ date: "5/1855", wounds: 180, other: 155, disease: 550 }),
+  OpenStruct.new({ date: "6/1855", wounds: 330, other: 130, disease: 650 }),
+  OpenStruct.new({ date: "7/1855", wounds: 260, other: 130, disease: 430 }),
+  OpenStruct.new({ date: "8/1855", wounds: 290, other: 110, disease: 490 }),
+  OpenStruct.new({ date: "9/1855", wounds: 355, other: 100, disease: 290 }),
+  OpenStruct.new({ date: "10/1855", wounds: 135, other: 95, disease: 245 }),
+  OpenStruct.new({ date: "11/1855", wounds: 100, other: 140, disease: 325 }),
+  OpenStruct.new({ date: "12/1855", wounds: 40, other: 120, disease: 215 }),
+  OpenStruct.new({ date: "1/1856", wounds: 0, other: 160, disease: 160 }),
+  OpenStruct.new({ date: "2/1856", wounds: 0, other: 100, disease: 100 }),
+  OpenStruct.new({ date: "3/1856", wounds: 0, other: 125, disease: 90 })
+];
+
+format= pv.Format::Date.new("%m/%Y");
+$crimea.each_with_index {|d,i|
+  d.date = format.parse(d.date)
+}
\ No newline at end of file
diff --git a/examples/4_pv_custom/crimea/crimea_grouped_bar.rb b/examples/4_pv_custom/crimea/crimea_grouped_bar.rb
new file mode 100644
index 0000000..9e390fb
--- /dev/null
+++ b/examples/4_pv_custom/crimea/crimea_grouped_bar.rb
@@ -0,0 +1,61 @@
+# = Crimeam War deaths (Grouped bar)
+# Florence Nightingale used a coxcomb diagram to emphasize the number of deaths due to “preventible or mitigable zymotic diseases”. This graph shows data using a stacked bar chart.
+$:.unshift(File.dirname(__FILE__)+"/../../../lib")
+require 'rubyvis'
+require 'ostruct'
+load(File.dirname(__FILE__)+"/crimea_data.rb")
+
+
+w = 545
+h = 280
+#x = pv.Scale.linear($crimea, lambda {|d| d.date}).range(0, w)
+
+x=pv.Scale.ordinal($crimea, lambda {|d| d.date}).split_banded(0,w,4/5.0)
+
+y = pv.Scale.linear(0, 1500).range(0, h)
+k=x.range_band / $causes.size
+fill = pv.colors("lightpink", "darkgray", "lightblue")
+
+format = pv.Format.date("%b")
+
+
+
+vis = pv.Panel.new()
+    .width(w)
+    .height(h)
+    .margin(19.5)
+    .right(40);
+    
+panel = vis.add(pv.Panel)
+    .data($crimea)
+    .left(lambda {|d| x.scale(d.date)})
+    .width(x.range_band);
+    
+panel.add(pv.Bar)
+    .data($causes)
+    .bottom(0)
+    .width(k)
+    .left(lambda { self.index * k})
+    .height(lambda {|t, d| y.scale(d.send(t))})
+    .fill_style(lambda {|f| a=fill.scale(self.index); return a})
+    .stroke_style(lambda {|d| fill_style ? fill_style.darker : pv.color('black')})
+    .line_width(1);
+
+panel.anchor("bottom").add(pv.Label)
+.visible(lambda { (self.index % 3)==0})
+.text_baseline("top")
+    .text_margin(10)
+    .text(lambda {|d| format.format(d.date)})
+    
+  
+vis.add(pv.Rule)
+    .data(y.ticks())
+    .bottom(lambda {|d| y.scale(d)})
+    .stroke_style(lambda {|i|  i!=0 ? pv.color("rgba(255, 255, 255, .5)") : pv.color("black")})
+  .anchor("right").add(pv.Label)
+  .visible(lambda { (self.index & 1)==0})
+    .text_margin(6);
+
+vis.render();
+
+puts vis.to_svg
diff --git a/examples/4_pv_custom/crimea/crimea_line.rb b/examples/4_pv_custom/crimea/crimea_line.rb
new file mode 100644
index 0000000..d9ff1d0
--- /dev/null
+++ b/examples/4_pv_custom/crimea/crimea_line.rb
@@ -0,0 +1,50 @@
+# = Crimeam War deaths (Grouped bar)
+# Florence Nightingale used a coxcomb diagram to emphasize the number of deaths due to “preventible or mitigable zymotic diseases”. This graph shows data using a line chart.
+
+$:.unshift(File.dirname(__FILE__)+"/../../../lib")
+require 'rubyvis'
+require 'ostruct'
+load(File.dirname(__FILE__)+"/crimea_data.rb")
+
+
+w = 545
+h = 280
+#x = pv.Scale.linear($crimea, lambda {|d| d.date}).range(0, w)
+x=pv.Scale.linear(Time.utc(1854,4), Time.utc(1856,3)).range(0, w)
+y = pv.Scale.linear(0, 1500).range(0, h)
+fill = pv.colors("lightpink", "darkgray", "lightblue")
+format = pv.Format.date("%b")
+
+
+vis = pv.Panel.new()
+    .width(w)
+    .height(h)
+    .margin(19.5)
+    .right(40);
+vis.add(pv.Panel)
+    .data($causes)
+  .add(pv.Line)
+    .data($crimea)
+    .left(lambda {|d|  x.scale(d.date)})
+    .bottom(lambda {|d,t|   y.scale(d.send(t))})
+    .stroke_style(fill.by(pv.parent))
+    .line_width(3)
+
+vis.add(pv.Label)
+    .data(x.ticks())
+    .left(lambda {|d| x.scale(d)})
+    .bottom(0)
+    .text_baseline("top")
+    .text_margin(5)
+    .text(pv.Format.date("%b").format_lambda);
+
+vis.add(pv.Rule)
+    .data(y.ticks())
+    .bottom(lambda {|d| y.scale(d)})
+    .stroke_style(lambda {|i|  i!=0 ? pv.color("#ccc") : pv.color("black")})
+  .anchor("right").add(pv.Label)
+  .visible(lambda { (self.index & 1)==0})
+    .text_margin(6);
+    vis.render();
+
+puts vis.to_svg
diff --git a/examples/5_pv_hierarchies/bubble_charts.rb b/examples/5_pv_hierarchies/bubble_charts.rb
new file mode 100644
index 0000000..6c464b0
--- /dev/null
+++ b/examples/5_pv_hierarchies/bubble_charts.rb
@@ -0,0 +1,61 @@
+# = Bubble charts
+# Bubble charts, such as those provided by "Many Eyes":http://manyeyes.alphaworks.ibm.com/manyeyes/page/Bubble_Chart.html, encode data in the area of circles. Although less perceptually accurate than bar charts, they can pack hundreds of values into a small space. A similar technique is the Dorling cartogram, where circles are positioned according to geography rather than arbitrarily. Here we compare the file sizes of the Rubyvis library files
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+
+def get_files(path)
+  h={}
+  Dir.glob("#{path}/*").each {|e|
+    next if File.expand_path(e)=~/pkg|web|vendor|doc|~/
+    pa=File.expand_path(e) 
+    if File.stat(pa).directory?
+      h[File.basename(pa)]=get_files(pa)
+    else
+      h[File.basename(pa)]=File.stat(pa).size
+    end
+  }
+  h
+end
+
+files=get_files(File.expand_path(File.dirname(__FILE__)+"/../../lib/"))
+
+classes = Rubyvis.nodes(Rubyvis.flatten(files).leaf(lambda {|v| v.is_a? Numeric}).array)
+
+
+classes[1,classes.size-1].each {|d|
+  #p d.node_value.keys
+  d.node_name = "/" + d.node_value[:keys].join("/")
+  i = d.node_name.rindex("/")
+  class << d
+    attr_accessor :class_name, :package_name
+  end
+  d.class_name = d.node_name[i+1,d.node_name.size-(i+1)].gsub(".rb","")
+  d.package_name = d.node_name[0,i]
+  d.node_value = d.node_value[:value]
+}
+# For pretty number formatting.
+format = Rubyvis.Format.number
+
+vis = Rubyvis::Panel.new.
+  width(600)
+    .height(600)
+c20=Rubyvis::Colors.category20()
+vis.add(pv.Layout.Pack)
+    .top(-50)
+    .bottom(-50)
+    .nodes(classes)
+    .size(lambda {|d| d.node_value})
+    .spacing(0)
+    .order(nil)
+  .node.add(Rubyvis::Dot)
+    .fill_style(lambda {|d| c20.scale(d.package_name)})
+    .stroke_style(lambda {|d| c20.scale(d.package_name).darker})
+    .visible(lambda {|d| d.parent_node})
+    .title(lambda {|d| d.node_name + ": " + format.format(d.node_value)})
+  .anchor("center").add(pv.Label)
+  .text(lambda {|d| d.class_name[0, Math.sqrt(d.node_value).to_i / 8]})
+
+vis.render();
+puts vis.to_svg
+
diff --git a/examples/5_pv_hierarchies/bubble_charts_matrix.rb b/examples/5_pv_hierarchies/bubble_charts_matrix.rb
new file mode 100644
index 0000000..1493a53
--- /dev/null
+++ b/examples/5_pv_hierarchies/bubble_charts_matrix.rb
@@ -0,0 +1,64 @@
+# = Bubble charts matrix
+# 
+# Why have one boring bubble chart when 
+# you can have 20 multicolor charts?
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+panes=20
+cols=2
+
+
+p_w=200
+p_h=150
+#p data
+w = 20+p_w*cols
+h = (panes/cols)*10+p_h*(panes/cols)
+
+colors20=Rubyvis::Colors.category20()
+c20=Rubyvis::Colors.category20().by(lambda {|n| n.parent_node}) 
+vis = pv.Panel.new()
+  .width(w)
+  .height(h)
+  .bottom(5)
+  .left(5)
+  .right(5)
+  .top(5)
+
+
+
+(0..panes).each do |i|
+  n=i%cols
+  m=(i/cols.to_f).floor
+  panel=vis.add(Rubyvis::Panel).
+  left(n*(p_w+10)).
+  top(m*(p_h+10)).
+  width(p_w).
+  height(p_h)
+
+  d=Rubyvis.nodes((i+1).times.map {|ii| rand(5)+1})
+  
+  
+  panel.anchor('top').add(Rubyvis::Label).text("n#{i+1}") 
+  
+  pack=panel.add(pv.Layout.Pack).
+    nodes(d).
+    size(lambda {|n| n.node_value})
+  
+  pack.node.add(Rubyvis::Dot).
+    visible( lambda {|n| n.parent_node}).
+    fill_style(lambda {|n|
+      colors20.scale(n.parent_node).
+        brighter((n.node_value) / 5.0)
+    }).
+    stroke_style(c20)
+  
+  pack.node_label.add(Rubyvis::Label).
+    visible( lambda {|n| n.parent_node}).
+    text(lambda {index})
+  
+end
+
+vis.render();
+puts vis.to_svg
+
diff --git a/examples/5_pv_hierarchies/circle_packing.rb b/examples/5_pv_hierarchies/circle_packing.rb
new file mode 100644
index 0000000..91d56fa
--- /dev/null
+++ b/examples/5_pv_hierarchies/circle_packing.rb
@@ -0,0 +1,54 @@
+# = Circle Packing
+# Enclosure diagrams are also space-filling, using containment rather than adjacency to represent the hierarchy. As with adjacency diagrams, the size of any node in the tree is quickly revealed. Although circle packing does not use space as efficiently as a treemap, the “wasted” space effectively reveals the hierarchy. At the same time, node sizes can be rapidly compared using area judgments.
+# By flattening the hierarchy, the pack layout can also be used to create "bubble charts":bubble_charts.html.
+# This example uses RBP API.
+
+
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+
+def get_files(path)
+  h={}
+  Dir.glob("#{path}/*").each {|e|
+    next if File.expand_path(e)=~/pkg|web|vendor|doc|~/
+    pa=File.expand_path(e) 
+    if File.stat(pa).directory?
+      h[File.basename(pa)]=get_files(pa)
+    else
+      h[File.basename(pa)]=File.stat(pa).size
+    end
+  }
+  h
+end
+
+files=get_files(File.expand_path(File.dirname(__FILE__)+"/../../lib/"))
+
+format = Rubyvis::Format.number();
+
+vis = Rubyvis::Panel.new do
+  width 600
+  height 796
+  margin 2
+  layout_pack do
+    nodes Rubyvis.dom(files).root("Rubyvis").nodes
+    size(lambda {|d| d.node_value})
+    node.dot do 
+      fill_style {|d| 
+        d.first_child ? "rgba(31, 119, 180, 0.25)" : "#ff7f0e"
+      }
+      title {|d| 
+        d.node_name.to_s + (d.first_child ? "" : ": " + format.format(d.node_value))
+      }
+      line_width 1
+    end
+    node_label.label do
+      visible {|d| !d.first_child}
+      text {|d| d.node_name[0, Math.sqrt(d.node_value) / 10]}
+    end
+  end
+end
+
+vis.render()
+puts vis.to_svg
+
diff --git a/examples/5_pv_hierarchies/dendogram.rb b/examples/5_pv_hierarchies/dendogram.rb
new file mode 100644
index 0000000..94b2958
--- /dev/null
+++ b/examples/5_pv_hierarchies/dendogram.rb
@@ -0,0 +1,52 @@
+# = Dendogram
+# A dendrogram (or cluster layout) is a node-link diagram that places leaf nodes of the tree at the same depth. In this example, the classes (orange leaf nodes) are aligned on the right edge, with the packages (blue internal nodes) to the left. As with other tree layouts, dendrograms can also be oriented radially. 
+# Uses Protovis API
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+
+def get_files(path)
+  h={}
+  Dir.glob("#{path}/*").each {|e|
+    next if File.expand_path(e)=~/pkg|web|vendor|doc|~/
+    pa=File.expand_path(e) 
+    if File.stat(pa).directory?
+      h[File.basename(pa)]=get_files(pa)
+    else
+      h[File.basename(pa)]=File.stat(pa).size
+    end
+  }
+  h
+end
+
+files=get_files(File.expand_path(File.dirname(__FILE__)+"/../../lib/"))
+
+
+vis = Rubyvis::Panel.new do
+  width 200
+  height 1500 
+  left 40 
+  right 160 
+  top 10 
+  bottom 10 
+  layout_cluster do
+    nodes pv.dom(files).root("rubyvis").sort(lambda {|a,b| a.node_name<=>b.node_name}).nodes
+    group 0.2
+    orient "left"
+
+    link.line  do
+      stroke_style "#ccc"
+      line_width 1
+      antialias false
+    end
+
+    node.dot do 
+      fill_style {|n| n.first_child ? "#aec7e8" : "#ff7f0e"}
+    end
+    
+    node_label.label
+  end
+end
+
+vis.render
+puts vis.to_svg
diff --git a/examples/5_pv_hierarchies/icicle.rb b/examples/5_pv_hierarchies/icicle.rb
new file mode 100644
index 0000000..a2cf1b4
--- /dev/null
+++ b/examples/5_pv_hierarchies/icicle.rb
@@ -0,0 +1,48 @@
+# = Icicle
+# An icicle is simply a sunburst transformed from polar to cartesian coordinates. Here we show the various files on Rubyvis package; the color of each cell corresponds to the package, while the area encodes the size of the source code in bytes 
+# Uses Protovis API
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+def get_files(path)
+  h={}
+  Dir.glob("#{path}/*").each {|e|
+    next if File.expand_path(e)=~/pkg|web|vendor|doc|~/
+    pa=File.expand_path(e) 
+    if File.stat(pa).directory?
+      h[File.basename(pa)]=get_files(pa)
+    else
+      h[File.basename(pa)]=File.stat(pa).size
+    end
+  }
+  h
+end
+
+files=get_files(File.expand_path(File.dirname(__FILE__)+"/../../lib/"))
+
+colors=Rubyvis::Colors.category19
+vis = Rubyvis::Panel.new.
+  width(600).
+  height(500).
+  bottom(30)
+
+layout = vis.add(Rubyvis::Layout::Partition::Fill).
+  nodes(Rubyvis.dom(files).root("rubyvis").nodes)
+layout.order("descending")
+layout.orient("top")
+layout.size(lambda {|d| d.node_value})
+
+layout.node.add(pv.Bar).
+  fill_style( lambda {|d|
+  colors.scale(d.parent_node ? d.parent_node.node_name : '')}
+  ).
+  stroke_style("rgba(255,255,255,.5)").
+  line_width(1).
+  antialias(false)
+
+layout.node_label.add(pv.Label)
+    .text_angle(-Math::PI / 2.0)
+    .visible(lambda {|d| d.dx >6 })
+vis.render()
+
+puts vis.to_svg
diff --git a/examples/5_pv_hierarchies/indent.rb b/examples/5_pv_hierarchies/indent.rb
new file mode 100644
index 0000000..b2df35e
--- /dev/null
+++ b/examples/5_pv_hierarchies/indent.rb
@@ -0,0 +1,71 @@
+# = Indented Tree
+# Indented trees are widely-used to represent file systems, among other applications. Although indented trees require much vertical space and do not easily facilitate multiscale inference, they do allow efficient interactive exploration of the tree to find a specific node.
+# In addition, the indent layout allows rapid scanning of node labels, and multivariate data such as file size can be displayed adjacent to the hierarchy.
+#
+# Uses Protovis API
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+
+def get_files(path)
+  h={}
+  Dir.glob("#{path}/*").each {|e|
+    next if File.expand_path(e)=~/pkg|web|vendor|doc|~/
+    pa=File.expand_path(e) 
+    if File.stat(pa).directory?
+      h[File.basename(pa)]=get_files(pa)
+    else
+      h[File.basename(pa)]=File.stat(pa).size
+    end
+  }
+  h
+end
+
+files=get_files(File.expand_path(File.dirname(__FILE__)+"/../../lib/"))
+
+
+root = Rubyvis.dom(files)
+    .root("rubyvis")
+    .sort(lambda {|a,b| a.node_name<=>b.node_name})
+
+#/* Recursively compute the package sizes. */
+root.visit_after {|n,i| 
+  if (n.first_child)
+    n.node_value= Rubyvis.sum(n.child_nodes , lambda {|nn|  nn.node_value})
+  end
+}
+
+def t(d)
+  d.parent_node ? (t(d.parent_node) + "." + d.node_name) : d.node_name
+end
+
+vis = Rubyvis::Panel.new()
+    .width(260)
+    .height((root.nodes.size + 1)* 12)
+    .margin(5)
+
+layout = vis.add(pv.Layout.Indent)
+.nodes(lambda {root.nodes})
+    .depth(12)
+    .breadth(12)
+
+layout.link.add(pv.Line)
+
+node = layout.node.add(pv.Panel)
+.top(lambda {|n| n.y - 6})
+    .height(12)
+    .right(6)
+    .strokeStyle(nil)
+    
+node.anchor("left").add(pv.Dot)
+    .strokeStyle("#1f77b4")
+    .fillStyle(lambda {|n| n.first_child ? "#aec7e8" : "#ff7f0e"})
+    .title(lambda {|d| t(d)})
+  .anchor("right").add(pv.Label)
+  .text(lambda {|n| n.node_name})
+
+node.anchor("right").add(pv.Label)
+.text(lambda {|n| (n.node_value >> 10).to_s + "KB"})
+
+vis.render()
+puts vis.to_svg
diff --git a/examples/5_pv_hierarchies/node_link_tree.rb b/examples/5_pv_hierarchies/node_link_tree.rb
new file mode 100644
index 0000000..699acc1
--- /dev/null
+++ b/examples/5_pv_hierarchies/node_link_tree.rb
@@ -0,0 +1,52 @@
+# = Node-Link Trees
+# The tree layout implements the Reingold-Tilford algorithm for efficient, tidy arrangement of layered nodes. This node-link diagram is similar to the dendrogram, except the depth of nodes is computed by distance from the root, leading to a ragged appearance. Cartesian orientations are also supported. 
+
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+def get_files(path)
+  h={}
+  Dir.glob("#{path}/*").each {|e|
+    next if File.expand_path(e)=~/pkg|web|vendor|doc|~/
+    pa=File.expand_path(e) 
+    if File.stat(pa).directory?
+      h[File.basename(pa)]=get_files(pa)
+    else
+      h[File.basename(pa)]=File.stat(pa).size
+    end
+  }
+  h
+end
+
+
+
+files=get_files(File.expand_path(File.dirname(__FILE__)+"/../../"))
+#files={:b=>{:c=>1,:d=>2}}
+
+
+vis = Rubyvis::Panel.new()
+    .width(800)
+    .height(800)
+    .left(0)
+    .right(0)
+    .top(0)
+    .bottom(0)
+
+tree = vis.add(Rubyvis::Layout::Tree).
+  nodes(Rubyvis.dom(files).root("rubyvis").nodes()).
+  orient('radial').
+  depth(85).
+  breadth(12)
+
+tree.link.add(Rubyvis::Line)
+
+tree.node.add(Rubyvis::Dot).
+fill_style(lambda {|n| n.first_child ? "#aec7e8" : "#ff7f0e"}).
+title(lambda {|n| n.node_name})
+
+tree.node_label.add(Rubyvis::Label).
+visible(lambda {|n| n.first_child})
+
+
+vis.render
+puts vis.to_svg
diff --git a/examples/5_pv_hierarchies/sunburst.rb b/examples/5_pv_hierarchies/sunburst.rb
new file mode 100644
index 0000000..dc95733
--- /dev/null
+++ b/examples/5_pv_hierarchies/sunburst.rb
@@ -0,0 +1,52 @@
+# = Sunbursts
+# A sunburst is an adjacency diagram: a space-filling variant of the node-link diagram. Rather than drawing a link between parent and child in the hierarchy, nodes are drawn as solid areas (either wedges or bars), and their placement relative to adjacent nodes reveals their position in the hierarchy. Because the nodes are now space-filling, we can use an angle encoding for the size of software files. This reveals an additional dimension that would be difficult to show in a node-link diagram.
+# This example show files and directory inside rubyvis lib directory and uses RBP API
+
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+def get_files(path)
+  h={}
+  Dir.glob("#{path}/*").each {|e|
+    next if File.expand_path(e)=~/pkg|web|vendor|doc|~/
+    pa=File.expand_path(e) 
+    if File.stat(pa).directory?
+      h[File.basename(pa)]=get_files(pa)
+    else
+      h[File.basename(pa)]=File.stat(pa).size
+    end
+  }
+  h
+end
+
+files=get_files(File.expand_path(File.dirname(__FILE__)+"/../../lib/rubyvis/"))
+
+#load(File.dirname(__FILE__)+"/treemap/treemap_data.rb")
+
+colors=Rubyvis::Colors.category19()
+
+vis = Rubyvis::Panel.new do
+  width 900
+  height 900
+  layout_partition_fill do    
+    nodes Rubyvis.dom(files).root("rubyvis").nodes
+    size {|d| d.node_value}
+    order "descending"
+    orient "radial"
+    
+    node.wedge do 
+      fill_style {|d| colors.scale(d.parent_node)}
+      stroke_style("#fff")
+      line_width(0.5)
+    end
+    
+    node_label.label do 
+      visible {|d| d.angle * d.outer_radius >= 10}
+    end
+    
+  end
+end
+vis.render
+
+
+puts vis.to_svg
diff --git a/examples/5_pv_hierarchies/treemap.rb b/examples/5_pv_hierarchies/treemap.rb
new file mode 100644
index 0000000..6fcc01b
--- /dev/null
+++ b/examples/5_pv_hierarchies/treemap.rb
@@ -0,0 +1,48 @@
+# = Treemap
+# Introduced by Ben Shneiderman in 1991, a treemap recursively subdivides area into rectangles. As with adjacency diagrams, the size of any node in the tree is quickly revealed. This example uses color to encode different packages of the rubyvis package, and area to encode file size. “Squarified” treemaps use approximately square rectangles, which offer better readability and size estimation than naive “slice-and-dice” subdivision. 
+# Fancier algorithms such as "Voronoi":http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.102.6281&rep=rep1&type=pdf and "jigsaw":http://www.research.ibm.com/visual/papers/158-wattenberg-final3.pdf treemaps also exist but are less common.
+
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+
+def get_files(path)
+  h={}
+  Dir.glob("#{path}/*").each {|e|
+    next if File.expand_path(e)=~/pkg|web|vendor|doc|~/
+    pa=File.expand_path(e) 
+    if File.stat(pa).directory?
+      h[File.basename(pa)]=get_files(pa)
+    else
+      h[File.basename(pa)]=File.stat(pa).size
+    end
+  }
+  h
+end
+
+files=get_files(File.expand_path(File.dirname(__FILE__)+"/../../lib/"))
+
+format=Rubyvis::Format.number
+color = pv.Colors.category20
+nodes = pv.dom(files).root("rubyvis").nodes
+
+
+vis = pv.Panel.new()
+    .width(600)
+    .height(1000)
+
+treemap = vis.add(Rubyvis::Layout::Treemap).
+  nodes(nodes).mode("squarify").round(true)
+
+treemap.leaf.add(Rubyvis::Panel).
+  fill_style(lambda{|d| 
+   color.scale(d.parent_node.node_name)}).
+  stroke_style("#fff").
+  line_width(1).
+  antialias(false).
+  title(lambda {|d| d.node_name+" "+format.format(d.node_value)})
+
+treemap.node_label.add(Rubyvis::Label).
+  text_style(lambda {|d| pv.rgb(0, 0, 0, 1)})
+
+vis.render
+puts vis.to_svg
diff --git a/examples/6_pv_networks/arc.rb b/examples/6_pv_networks/arc.rb
new file mode 100644
index 0000000..7b7f332
--- /dev/null
+++ b/examples/6_pv_networks/arc.rb
@@ -0,0 +1,32 @@
+# = Arc Diagrams
+# An arc diagram uses a one-dimensional layout of nodes, with circular arcs to represent links. Though an arc diagram may not convey the overall structure of the graph as effectively as a two-dimensional layout, with a good ordering of nodes it is easy to identify cliques and bridges. Further, as with the indented tree, multivariate data can easily be displayed alongside nodes.
+# This network represents character co-occurrence in the chapters of Victor Hugo's classic novel, Les Misérables. Node colors depict cluster memberships computed by a community-detection algorithm. Source: Knuth, D. E. 1993. The Stanford GraphBase: A Platform for Combinatorial Computing, Addison-Wesley. 
+
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+load(File.dirname(__FILE__)+"/miserables_data.rb")
+c=Rubyvis::Colors.category19()
+
+vis = Rubyvis::Panel.new() do 
+  width 880
+  height 310
+  bottom 90
+  layout_arc do
+    nodes $miserables.nodes
+    links $miserables.links
+    sort {|a,b| 
+    a.group==b.group ? b.link_degree<=>a.link_degree : b.group <=>a.group}
+
+    link.line
+    
+    node.dot do
+      shape_size {|d| d.link_degree + 4}
+      fill_style {|d| c[d.group]}
+      stroke_style {|d| c[d.group].darker()}
+    end
+    
+    node_label.label
+  end
+end
+vis.render();
+puts vis.to_svg
diff --git a/examples/6_pv_networks/matrix.rb b/examples/6_pv_networks/matrix.rb
new file mode 100644
index 0000000..2ab3644
--- /dev/null
+++ b/examples/6_pv_networks/matrix.rb
@@ -0,0 +1,34 @@
+# = Matrix Diagrams
+# A graph can be represented by an adjacency matrix, where each value in row i and column j corresponds to the link from node i to node j. Given this representation, an obvious visualization then is: show the matrix! Using color or saturation instead of text allows patterns to be perceived rapidly. The seriation problem applies just as much to the matrix view as to the arc diagram, so the order of rows and columns is important: here we use a community-detection algorithm to order and col [...]
+# While path following is harder in a matrix view than in a node-link diagram, matrices have a number of compensating advantages. As networks get large and highly connected, node-link diagrams often devolve into giant hairballs of line crossings. In matrix views, however, line crossings are impossible, and with an effective sorting one quickly can spot clusters and bridges. Allowing interactive grouping and reordering of the matrix facilitates deeper exploration of network structure.
+# This network represents character co-occurrence in the chapters of Victor Hugo's classic novel, Les Misérables. Node colors depict cluster memberships computed by a community-detection algorithm. Source: Knuth, D. E. 1993. The Stanford GraphBase: A Platform for Combinatorial Computing, Addison-Wesley. 
+
+$:.unshift(File.dirname(__FILE__)+"/../../lib")
+require 'rubyvis'
+load(File.dirname(__FILE__)+"/miserables_data.rb")
+color=Rubyvis::Colors.category19
+
+
+vis = Rubyvis::Panel.new() do 
+  width 693
+  height 693
+  top 90
+  left 90
+  layout_matrix do
+    nodes $miserables.nodes
+    links $miserables.links
+    sort {|a,b| b.group<=>a.group }
+    directed (false)
+    link.bar do
+      fill_style {|l| l.link_value!=0 ?
+       ((l.target_node.group == l.source_node.group) ? color[l.source_node.group] : "#555") : "#eee"}
+      antialias(false)
+      line_width(1)
+    end
+    node_label.label do 
+      text_style {|l| color[l.group]}
+    end
+  end
+end
+vis.render()
+puts vis.to_svg
diff --git a/examples/6_pv_networks/miserables_data.rb b/examples/6_pv_networks/miserables_data.rb
new file mode 100644
index 0000000..16f4c9b
--- /dev/null
+++ b/examples/6_pv_networks/miserables_data.rb
@@ -0,0 +1,348 @@
+# This file contains the weighted network of coappearances of characters in
+# Victor Hugo's novel "Les Miserables". Nodes represent characters as indicated
+# by the labels, and edges connect any pair of characters that appear in the
+# same chapter of the book. The values on the edges are the number of such
+# coappearances. The data on coappearances were taken from D. E. Knuth, The
+# Stanford GraphBase: A Platform for Combinatorial Computing, Addison-Wesley,
+# Reading, MA (1993).
+#
+# The group labels were transcribed from "Finding and evaluating community
+# structure in networks" by M. E. J. Newman and M. Girvan.
+
+$miserables = OpenStruct.new({
+  :nodes=>[
+    OpenStruct.new({:node_value=>"Myriel", :group=>1}),
+    OpenStruct.new({:node_value=>"Napoleon", :group=>1}),
+    OpenStruct.new({:node_value=>"Mlle. Baptistine", :group=>1}),
+    OpenStruct.new({:node_value=>"Mme. Magloire", :group=>1}),
+    OpenStruct.new({:node_value=>"Countess de Lo", :group=>1}),
+    OpenStruct.new({:node_value=>"Geborand", :group=>1}),
+    OpenStruct.new({:node_value=>"Champtercier", :group=>1}),
+    OpenStruct.new({:node_value=>"Cravatte", :group=>1}),
+    OpenStruct.new({:node_value=>"Count", :group=>1}),
+    OpenStruct.new({:node_value=>"Old Man", :group=>1}),
+    OpenStruct.new({:node_value=>"Labarre", :group=>2}),
+    OpenStruct.new({:node_value=>"Valjean", :group=>2}),
+    OpenStruct.new({:node_value=>"Marguerite", :group=>3}),
+    OpenStruct.new({:node_value=>"Mme. de R", :group=>2}),
+    OpenStruct.new({:node_value=>"Isabeau", :group=>2}),
+    OpenStruct.new({:node_value=>"Gervais", :group=>2}),
+    OpenStruct.new({:node_value=>"Tholomyes", :group=>3}),
+    OpenStruct.new({:node_value=>"Listolier", :group=>3}),
+    OpenStruct.new({:node_value=>"Fameuil", :group=>3}),
+    OpenStruct.new({:node_value=>"Blacheville", :group=>3}),
+    OpenStruct.new({:node_value=>"Favourite", :group=>3}),
+    OpenStruct.new({:node_value=>"Dahlia", :group=>3}),
+    OpenStruct.new({:node_value=>"Zephine", :group=>3}),
+    OpenStruct.new({:node_value=>"Fantine", :group=>3}),
+    OpenStruct.new({:node_value=>"Mme. Thenardier", :group=>4}),
+    OpenStruct.new({:node_value=>"Thenardier", :group=>4}),
+    OpenStruct.new({:node_value=>"Cosette", :group=>5}),
+    OpenStruct.new({:node_value=>"Javert", :group=>4}),
+    OpenStruct.new({:node_value=>"Fauchelevent", :group=>0}),
+    OpenStruct.new({:node_value=>"Bamatabois", :group=>2}),
+    OpenStruct.new({:node_value=>"Perpetue", :group=>3}),
+    OpenStruct.new({:node_value=>"Simplice", :group=>2}),
+    OpenStruct.new({:node_value=>"Scaufflaire", :group=>2}),
+    OpenStruct.new({:node_value=>"Woman 1", :group=>2}),
+    OpenStruct.new({:node_value=>"Judge", :group=>2}),
+    OpenStruct.new({:node_value=>"Champmathieu", :group=>2}),
+    OpenStruct.new({:node_value=>"Brevet", :group=>2}),
+    OpenStruct.new({:node_value=>"Chenildieu", :group=>2}),
+    OpenStruct.new({:node_value=>"Cochepaille", :group=>2}),
+    OpenStruct.new({:node_value=>"Pontmercy", :group=>4}),
+    OpenStruct.new({:node_value=>"Boulatruelle", :group=>6}),
+    OpenStruct.new({:node_value=>"Eponine", :group=>4}),
+    OpenStruct.new({:node_value=>"Anzelma", :group=>4}),
+    OpenStruct.new({:node_value=>"Woman 2", :group=>5}),
+    OpenStruct.new({:node_value=>"Mother Innocent", :group=>0}),
+    OpenStruct.new({:node_value=>"Gribier", :group=>0}),
+    OpenStruct.new({:node_value=>"Jondrette", :group=>7}),
+    OpenStruct.new({:node_value=>"Mme. Burgon", :group=>7}),
+    OpenStruct.new({:node_value=>"Gavroche", :group=>8}),
+    OpenStruct.new({:node_value=>"Gillenormand", :group=>5}),
+    OpenStruct.new({:node_value=>"Magnon", :group=>5}),
+    OpenStruct.new({:node_value=>"Mlle. Gillenormand", :group=>5}),
+    OpenStruct.new({:node_value=>"Mme. Pontmercy", :group=>5}),
+    OpenStruct.new({:node_value=>"Mlle. Vaubois", :group=>5}),
+    OpenStruct.new({:node_value=>"Lt. Gillenormand", :group=>5}),
+    OpenStruct.new({:node_value=>"Marius", :group=>8}),
+    OpenStruct.new({:node_value=>"Baroness T", :group=>5}),
+    OpenStruct.new({:node_value=>"Mabeuf", :group=>8}),
+    OpenStruct.new({:node_value=>"Enjolras", :group=>8}),
+    OpenStruct.new({:node_value=>"Combeferre", :group=>8}),
+    OpenStruct.new({:node_value=>"Prouvaire", :group=>8}),
+    OpenStruct.new({:node_value=>"Feuilly", :group=>8}),
+    OpenStruct.new({:node_value=>"Courfeyrac", :group=>8}),
+    OpenStruct.new({:node_value=>"Bahorel", :group=>8}),
+    OpenStruct.new({:node_value=>"Bossuet", :group=>8}),
+    OpenStruct.new({:node_value=>"Joly", :group=>8}),
+    OpenStruct.new({:node_value=>"Grantaire", :group=>8}),
+    OpenStruct.new({:node_value=>"Mother Plutarch", :group=>9}),
+    OpenStruct.new({:node_value=>"Gueulemer", :group=>4}),
+    OpenStruct.new({:node_value=>"Babet", :group=>4}),
+    OpenStruct.new({:node_value=>"Claquesous", :group=>4}),
+    OpenStruct.new({:node_value=>"Montparnasse", :group=>4}),
+    OpenStruct.new({:node_value=>"Toussaint", :group=>5}),
+    OpenStruct.new({:node_value=>"Child 1", :group=>10}),
+    OpenStruct.new({:node_value=>"Child 2", :group=>10}),
+    OpenStruct.new({:node_value=>"Brujon", :group=>4}),
+    OpenStruct.new({:node_value=>"Mme. Hucheloup", :group=>8})
+  ],
+  :links=>[
+    OpenStruct.new({:source=>1, :target=>0, :value=>1}),
+    OpenStruct.new({:source=>2, :target=>0, :value=>8}),
+    OpenStruct.new({:source=>3, :target=>0, :value=>10}),
+    OpenStruct.new({:source=>3, :target=>2, :value=>6}),
+    OpenStruct.new({:source=>4, :target=>0, :value=>1}),
+    OpenStruct.new({:source=>5, :target=>0, :value=>1}),
+    OpenStruct.new({:source=>6, :target=>0, :value=>1}),
+    OpenStruct.new({:source=>7, :target=>0, :value=>1}),
+    OpenStruct.new({:source=>8, :target=>0, :value=>2}),
+    OpenStruct.new({:source=>9, :target=>0, :value=>1}),
+    OpenStruct.new({:source=>11, :target=>10, :value=>1}),
+    OpenStruct.new({:source=>11, :target=>3, :value=>3}),
+    OpenStruct.new({:source=>11, :target=>2, :value=>3}),
+    OpenStruct.new({:source=>11, :target=>0, :value=>5}),
+    OpenStruct.new({:source=>12, :target=>11, :value=>1}),
+    OpenStruct.new({:source=>13, :target=>11, :value=>1}),
+    OpenStruct.new({:source=>14, :target=>11, :value=>1}),
+    OpenStruct.new({:source=>15, :target=>11, :value=>1}),
+    OpenStruct.new({:source=>17, :target=>16, :value=>4}),
+    OpenStruct.new({:source=>18, :target=>16, :value=>4}),
+    OpenStruct.new({:source=>18, :target=>17, :value=>4}),
+    OpenStruct.new({:source=>19, :target=>16, :value=>4}),
+    OpenStruct.new({:source=>19, :target=>17, :value=>4}),
+    OpenStruct.new({:source=>19, :target=>18, :value=>4}),
+    OpenStruct.new({:source=>20, :target=>16, :value=>3}),
+    OpenStruct.new({:source=>20, :target=>17, :value=>3}),
+    OpenStruct.new({:source=>20, :target=>18, :value=>3}),
+    OpenStruct.new({:source=>20, :target=>19, :value=>4}),
+    OpenStruct.new({:source=>21, :target=>16, :value=>3}),
+    OpenStruct.new({:source=>21, :target=>17, :value=>3}),
+    OpenStruct.new({:source=>21, :target=>18, :value=>3}),
+    OpenStruct.new({:source=>21, :target=>19, :value=>3}),
+    OpenStruct.new({:source=>21, :target=>20, :value=>5}),
+    OpenStruct.new({:source=>22, :target=>16, :value=>3}),
+    OpenStruct.new({:source=>22, :target=>17, :value=>3}),
+    OpenStruct.new({:source=>22, :target=>18, :value=>3}),
+    OpenStruct.new({:source=>22, :target=>19, :value=>3}),
+    OpenStruct.new({:source=>22, :target=>20, :value=>4}),
+    OpenStruct.new({:source=>22, :target=>21, :value=>4}),
+    OpenStruct.new({:source=>23, :target=>16, :value=>3}),
+    OpenStruct.new({:source=>23, :target=>17, :value=>3}),
+    OpenStruct.new({:source=>23, :target=>18, :value=>3}),
+    OpenStruct.new({:source=>23, :target=>19, :value=>3}),
+    OpenStruct.new({:source=>23, :target=>20, :value=>4}),
+    OpenStruct.new({:source=>23, :target=>21, :value=>4}),
+    OpenStruct.new({:source=>23, :target=>22, :value=>4}),
+    OpenStruct.new({:source=>23, :target=>12, :value=>2}),
+    OpenStruct.new({:source=>23, :target=>11, :value=>9}),
+    OpenStruct.new({:source=>24, :target=>23, :value=>2}),
+    OpenStruct.new({:source=>24, :target=>11, :value=>7}),
+    OpenStruct.new({:source=>25, :target=>24, :value=>13}),
+    OpenStruct.new({:source=>25, :target=>23, :value=>1}),
+    OpenStruct.new({:source=>25, :target=>11, :value=>12}),
+    OpenStruct.new({:source=>26, :target=>24, :value=>4}),
+    OpenStruct.new({:source=>26, :target=>11, :value=>31}),
+    OpenStruct.new({:source=>26, :target=>16, :value=>1}),
+    OpenStruct.new({:source=>26, :target=>25, :value=>1}),
+    OpenStruct.new({:source=>27, :target=>11, :value=>17}),
+    OpenStruct.new({:source=>27, :target=>23, :value=>5}),
+    OpenStruct.new({:source=>27, :target=>25, :value=>5}),
+    OpenStruct.new({:source=>27, :target=>24, :value=>1}),
+    OpenStruct.new({:source=>27, :target=>26, :value=>1}),
+    OpenStruct.new({:source=>28, :target=>11, :value=>8}),
+    OpenStruct.new({:source=>28, :target=>27, :value=>1}),
+    OpenStruct.new({:source=>29, :target=>23, :value=>1}),
+    OpenStruct.new({:source=>29, :target=>27, :value=>1}),
+    OpenStruct.new({:source=>29, :target=>11, :value=>2}),
+    OpenStruct.new({:source=>30, :target=>23, :value=>1}),
+    OpenStruct.new({:source=>31, :target=>30, :value=>2}),
+    OpenStruct.new({:source=>31, :target=>11, :value=>3}),
+    OpenStruct.new({:source=>31, :target=>23, :value=>2}),
+    OpenStruct.new({:source=>31, :target=>27, :value=>1}),
+    OpenStruct.new({:source=>32, :target=>11, :value=>1}),
+    OpenStruct.new({:source=>33, :target=>11, :value=>2}),
+    OpenStruct.new({:source=>33, :target=>27, :value=>1}),
+    OpenStruct.new({:source=>34, :target=>11, :value=>3}),
+    OpenStruct.new({:source=>34, :target=>29, :value=>2}),
+    OpenStruct.new({:source=>35, :target=>11, :value=>3}),
+    OpenStruct.new({:source=>35, :target=>34, :value=>3}),
+    OpenStruct.new({:source=>35, :target=>29, :value=>2}),
+    OpenStruct.new({:source=>36, :target=>34, :value=>2}),
+    OpenStruct.new({:source=>36, :target=>35, :value=>2}),
+    OpenStruct.new({:source=>36, :target=>11, :value=>2}),
+    OpenStruct.new({:source=>36, :target=>29, :value=>1}),
+    OpenStruct.new({:source=>37, :target=>34, :value=>2}),
+    OpenStruct.new({:source=>37, :target=>35, :value=>2}),
+    OpenStruct.new({:source=>37, :target=>36, :value=>2}),
+    OpenStruct.new({:source=>37, :target=>11, :value=>2}),
+    OpenStruct.new({:source=>37, :target=>29, :value=>1}),
+    OpenStruct.new({:source=>38, :target=>34, :value=>2}),
+    OpenStruct.new({:source=>38, :target=>35, :value=>2}),
+    OpenStruct.new({:source=>38, :target=>36, :value=>2}),
+    OpenStruct.new({:source=>38, :target=>37, :value=>2}),
+    OpenStruct.new({:source=>38, :target=>11, :value=>2}),
+    OpenStruct.new({:source=>38, :target=>29, :value=>1}),
+    OpenStruct.new({:source=>39, :target=>25, :value=>1}),
+    OpenStruct.new({:source=>40, :target=>25, :value=>1}),
+    OpenStruct.new({:source=>41, :target=>24, :value=>2}),
+    OpenStruct.new({:source=>41, :target=>25, :value=>3}),
+    OpenStruct.new({:source=>42, :target=>41, :value=>2}),
+    OpenStruct.new({:source=>42, :target=>25, :value=>2}),
+    OpenStruct.new({:source=>42, :target=>24, :value=>1}),
+    OpenStruct.new({:source=>43, :target=>11, :value=>3}),
+    OpenStruct.new({:source=>43, :target=>26, :value=>1}),
+    OpenStruct.new({:source=>43, :target=>27, :value=>1}),
+    OpenStruct.new({:source=>44, :target=>28, :value=>3}),
+    OpenStruct.new({:source=>44, :target=>11, :value=>1}),
+    OpenStruct.new({:source=>45, :target=>28, :value=>2}),
+    OpenStruct.new({:source=>47, :target=>46, :value=>1}),
+    OpenStruct.new({:source=>48, :target=>47, :value=>2}),
+    OpenStruct.new({:source=>48, :target=>25, :value=>1}),
+    OpenStruct.new({:source=>48, :target=>27, :value=>1}),
+    OpenStruct.new({:source=>48, :target=>11, :value=>1}),
+    OpenStruct.new({:source=>49, :target=>26, :value=>3}),
+    OpenStruct.new({:source=>49, :target=>11, :value=>2}),
+    OpenStruct.new({:source=>50, :target=>49, :value=>1}),
+    OpenStruct.new({:source=>50, :target=>24, :value=>1}),
+    OpenStruct.new({:source=>51, :target=>49, :value=>9}),
+    OpenStruct.new({:source=>51, :target=>26, :value=>2}),
+    OpenStruct.new({:source=>51, :target=>11, :value=>2}),
+    OpenStruct.new({:source=>52, :target=>51, :value=>1}),
+    OpenStruct.new({:source=>52, :target=>39, :value=>1}),
+    OpenStruct.new({:source=>53, :target=>51, :value=>1}),
+    OpenStruct.new({:source=>54, :target=>51, :value=>2}),
+    OpenStruct.new({:source=>54, :target=>49, :value=>1}),
+    OpenStruct.new({:source=>54, :target=>26, :value=>1}),
+    OpenStruct.new({:source=>55, :target=>51, :value=>6}),
+    OpenStruct.new({:source=>55, :target=>49, :value=>12}),
+    OpenStruct.new({:source=>55, :target=>39, :value=>1}),
+    OpenStruct.new({:source=>55, :target=>54, :value=>1}),
+    OpenStruct.new({:source=>55, :target=>26, :value=>21}),
+    OpenStruct.new({:source=>55, :target=>11, :value=>19}),
+    OpenStruct.new({:source=>55, :target=>16, :value=>1}),
+    OpenStruct.new({:source=>55, :target=>25, :value=>2}),
+    OpenStruct.new({:source=>55, :target=>41, :value=>5}),
+    OpenStruct.new({:source=>55, :target=>48, :value=>4}),
+    OpenStruct.new({:source=>56, :target=>49, :value=>1}),
+    OpenStruct.new({:source=>56, :target=>55, :value=>1}),
+    OpenStruct.new({:source=>57, :target=>55, :value=>1}),
+    OpenStruct.new({:source=>57, :target=>41, :value=>1}),
+    OpenStruct.new({:source=>57, :target=>48, :value=>1}),
+    OpenStruct.new({:source=>58, :target=>55, :value=>7}),
+    OpenStruct.new({:source=>58, :target=>48, :value=>7}),
+    OpenStruct.new({:source=>58, :target=>27, :value=>6}),
+    OpenStruct.new({:source=>58, :target=>57, :value=>1}),
+    OpenStruct.new({:source=>58, :target=>11, :value=>4}),
+    OpenStruct.new({:source=>59, :target=>58, :value=>15}),
+    OpenStruct.new({:source=>59, :target=>55, :value=>5}),
+    OpenStruct.new({:source=>59, :target=>48, :value=>6}),
+    OpenStruct.new({:source=>59, :target=>57, :value=>2}),
+    OpenStruct.new({:source=>60, :target=>48, :value=>1}),
+    OpenStruct.new({:source=>60, :target=>58, :value=>4}),
+    OpenStruct.new({:source=>60, :target=>59, :value=>2}),
+    OpenStruct.new({:source=>61, :target=>48, :value=>2}),
+    OpenStruct.new({:source=>61, :target=>58, :value=>6}),
+    OpenStruct.new({:source=>61, :target=>60, :value=>2}),
+    OpenStruct.new({:source=>61, :target=>59, :value=>5}),
+    OpenStruct.new({:source=>61, :target=>57, :value=>1}),
+    OpenStruct.new({:source=>61, :target=>55, :value=>1}),
+    OpenStruct.new({:source=>62, :target=>55, :value=>9}),
+    OpenStruct.new({:source=>62, :target=>58, :value=>17}),
+    OpenStruct.new({:source=>62, :target=>59, :value=>13}),
+    OpenStruct.new({:source=>62, :target=>48, :value=>7}),
+    OpenStruct.new({:source=>62, :target=>57, :value=>2}),
+    OpenStruct.new({:source=>62, :target=>41, :value=>1}),
+    OpenStruct.new({:source=>62, :target=>61, :value=>6}),
+    OpenStruct.new({:source=>62, :target=>60, :value=>3}),
+    OpenStruct.new({:source=>63, :target=>59, :value=>5}),
+    OpenStruct.new({:source=>63, :target=>48, :value=>5}),
+    OpenStruct.new({:source=>63, :target=>62, :value=>6}),
+    OpenStruct.new({:source=>63, :target=>57, :value=>2}),
+    OpenStruct.new({:source=>63, :target=>58, :value=>4}),
+    OpenStruct.new({:source=>63, :target=>61, :value=>3}),
+    OpenStruct.new({:source=>63, :target=>60, :value=>2}),
+    OpenStruct.new({:source=>63, :target=>55, :value=>1}),
+    OpenStruct.new({:source=>64, :target=>55, :value=>5}),
+    OpenStruct.new({:source=>64, :target=>62, :value=>12}),
+    OpenStruct.new({:source=>64, :target=>48, :value=>5}),
+    OpenStruct.new({:source=>64, :target=>63, :value=>4}),
+    OpenStruct.new({:source=>64, :target=>58, :value=>10}),
+    OpenStruct.new({:source=>64, :target=>61, :value=>6}),
+    OpenStruct.new({:source=>64, :target=>60, :value=>2}),
+    OpenStruct.new({:source=>64, :target=>59, :value=>9}),
+    OpenStruct.new({:source=>64, :target=>57, :value=>1}),
+    OpenStruct.new({:source=>64, :target=>11, :value=>1}),
+    OpenStruct.new({:source=>65, :target=>63, :value=>5}),
+    OpenStruct.new({:source=>65, :target=>64, :value=>7}),
+    OpenStruct.new({:source=>65, :target=>48, :value=>3}),
+    OpenStruct.new({:source=>65, :target=>62, :value=>5}),
+    OpenStruct.new({:source=>65, :target=>58, :value=>5}),
+    OpenStruct.new({:source=>65, :target=>61, :value=>5}),
+    OpenStruct.new({:source=>65, :target=>60, :value=>2}),
+    OpenStruct.new({:source=>65, :target=>59, :value=>5}),
+    OpenStruct.new({:source=>65, :target=>57, :value=>1}),
+    OpenStruct.new({:source=>65, :target=>55, :value=>2}),
+    OpenStruct.new({:source=>66, :target=>64, :value=>3}),
+    OpenStruct.new({:source=>66, :target=>58, :value=>3}),
+    OpenStruct.new({:source=>66, :target=>59, :value=>1}),
+    OpenStruct.new({:source=>66, :target=>62, :value=>2}),
+    OpenStruct.new({:source=>66, :target=>65, :value=>2}),
+    OpenStruct.new({:source=>66, :target=>48, :value=>1}),
+    OpenStruct.new({:source=>66, :target=>63, :value=>1}),
+    OpenStruct.new({:source=>66, :target=>61, :value=>1}),
+    OpenStruct.new({:source=>66, :target=>60, :value=>1}),
+    OpenStruct.new({:source=>67, :target=>57, :value=>3}),
+    OpenStruct.new({:source=>68, :target=>25, :value=>5}),
+    OpenStruct.new({:source=>68, :target=>11, :value=>1}),
+    OpenStruct.new({:source=>68, :target=>24, :value=>1}),
+    OpenStruct.new({:source=>68, :target=>27, :value=>1}),
+    OpenStruct.new({:source=>68, :target=>48, :value=>1}),
+    OpenStruct.new({:source=>68, :target=>41, :value=>1}),
+    OpenStruct.new({:source=>69, :target=>25, :value=>6}),
+    OpenStruct.new({:source=>69, :target=>68, :value=>6}),
+    OpenStruct.new({:source=>69, :target=>11, :value=>1}),
+    OpenStruct.new({:source=>69, :target=>24, :value=>1}),
+    OpenStruct.new({:source=>69, :target=>27, :value=>2}),
+    OpenStruct.new({:source=>69, :target=>48, :value=>1}),
+    OpenStruct.new({:source=>69, :target=>41, :value=>1}),
+    OpenStruct.new({:source=>70, :target=>25, :value=>4}),
+    OpenStruct.new({:source=>70, :target=>69, :value=>4}),
+    OpenStruct.new({:source=>70, :target=>68, :value=>4}),
+    OpenStruct.new({:source=>70, :target=>11, :value=>1}),
+    OpenStruct.new({:source=>70, :target=>24, :value=>1}),
+    OpenStruct.new({:source=>70, :target=>27, :value=>1}),
+    OpenStruct.new({:source=>70, :target=>41, :value=>1}),
+    OpenStruct.new({:source=>70, :target=>58, :value=>1}),
+    OpenStruct.new({:source=>71, :target=>27, :value=>1}),
+    OpenStruct.new({:source=>71, :target=>69, :value=>2}),
+    OpenStruct.new({:source=>71, :target=>68, :value=>2}),
+    OpenStruct.new({:source=>71, :target=>70, :value=>2}),
+    OpenStruct.new({:source=>71, :target=>11, :value=>1}),
+    OpenStruct.new({:source=>71, :target=>48, :value=>1}),
+    OpenStruct.new({:source=>71, :target=>41, :value=>1}),
+    OpenStruct.new({:source=>71, :target=>25, :value=>1}),
+    OpenStruct.new({:source=>72, :target=>26, :value=>2}),
+    OpenStruct.new({:source=>72, :target=>27, :value=>1}),
+    OpenStruct.new({:source=>72, :target=>11, :value=>1}),
+    OpenStruct.new({:source=>73, :target=>48, :value=>2}),
+    OpenStruct.new({:source=>74, :target=>48, :value=>2}),
+    OpenStruct.new({:source=>74, :target=>73, :value=>3}),
+    OpenStruct.new({:source=>75, :target=>69, :value=>3}),
+    OpenStruct.new({:source=>75, :target=>68, :value=>3}),
+    OpenStruct.new({:source=>75, :target=>25, :value=>3}),
+    OpenStruct.new({:source=>75, :target=>48, :value=>1}),
+    OpenStruct.new({:source=>75, :target=>41, :value=>1}),
+    OpenStruct.new({:source=>75, :target=>70, :value=>1}),
+    OpenStruct.new({:source=>75, :target=>71, :value=>1}),
+    OpenStruct.new({:source=>76, :target=>64, :value=>1}),
+    OpenStruct.new({:source=>76, :target=>65, :value=>1}),
+    OpenStruct.new({:source=>76, :target=>66, :value=>1}),
+    OpenStruct.new({:source=>76, :target=>63, :value=>1}),
+    OpenStruct.new({:source=>76, :target=>62, :value=>1}),
+    OpenStruct.new({:source=>76, :target=>48, :value=>1}),
+    OpenStruct.new({:source=>76, :target=>58, :value=>1})
+  ]
+})
diff --git a/lib/rubyvis.rb b/lib/rubyvis.rb
new file mode 100644
index 0000000..64759d4
--- /dev/null
+++ b/lib/rubyvis.rb
@@ -0,0 +1,109 @@
+require 'date'
+require 'ostruct'
+require 'rexml/document'
+require 'rexml/formatters/default'
+
+require 'pp'
+require 'rubyvis/internals'
+require 'rubyvis/vector'
+
+require 'rubyvis/sceneelement'
+require 'rubyvis/property'
+require 'rubyvis/nest'
+require 'rubyvis/flatten'
+
+require 'rubyvis/javascript_behaviour'
+require 'rubyvis/format'
+require 'rubyvis/mark'
+require 'rubyvis/scale'
+require 'rubyvis/histogram'
+
+require 'rubyvis/color/color'
+require 'rubyvis/color/colors'
+
+require 'rubyvis/layout'
+require 'rubyvis/dom'
+
+require 'rubyvis/scene/svg_scene'
+require 'rubyvis/transform'
+require 'rubyvis/mark/shorcut_methods'
+
+# = Rubyvis
+# Ruby port of Protovis
+# 
+module Rubyvis
+  @@nokogiri=nil
+  # Rubyvis version
+  VERSION = '0.5.2' 
+  # Protovis API on which current Rubyvis is based
+  PROTOVIS_API_VERSION='3.3'
+  # You actually can do it! http://snipplr.com/view/2137/uses-for-infinity-in-ruby/
+  Infinity=1.0 / 0 
+  #
+  # :section: basic methods
+  #
+  
+  # Returns the passed-in argument, +x+; the identity function. This method
+  # is provided for convenience since it is used as the default behavior for a
+  # number of property functions.
+  #
+  # @param [Object] x, a value.
+  # @return [Object] the value +x+.
+  def self.identity
+    lambda {|x,*args| x}
+  end
+  def self.has_nokogiri?
+    if @@nokogiri.nil?
+      begin
+        require 'nokogiri'
+        @@nokogiri=true
+      rescue LoadError
+        @@nokogiri=false
+      end
+    end
+    @@nokogiri
+  end
+  def self.xml_engine
+    if has_nokogiri? and !$rubyvis_no_nokogiri
+      :nokogiri
+    else
+      :rexml
+    end
+  end
+
+  
+  def self.nokogiri_document(v=nil)
+    if !v.nil?
+      @@nokogiri_document=v
+    end
+    @@nokogiri_document
+  end
+ # Returns <tt>self.index</tt>. This method is provided for convenience for use
+ # with scales. For example, to color bars by their index, say:
+ #
+ # <pre>.fill_style(Rubyvis::Colors.category10().by(Rubyvis.index))</pre>
+ #
+ # This method is equivalent to <tt>lambda {self.index}</tt>, but more
+ # succinct. Note that the <tt>index</tt> property is also supported for
+ # accessor functions with {@link Rubyvis.max}, {@link Rubyvis.min} and other array
+ # utility methods.
+ #
+ # @see Rubyvis::Scale
+ # @see Rubyvis::Mark#index
+  def self.index
+    lambda {|*args| self.index}
+  end
+  
+  def self.child
+    lambda {|*args| self.child_index}
+  end
+  def self.parent
+    lambda {|*args| self.parent.index}
+  end
+end
+
+# Alias for Rubyvis module
+# @return [Module] Rubyvis module
+def pv
+  Rubyvis
+end
diff --git a/lib/rubyvis/color/color.rb b/lib/rubyvis/color/color.rb
new file mode 100644
index 0000000..ce28d3a
--- /dev/null
+++ b/lib/rubyvis/color/color.rb
@@ -0,0 +1,426 @@
+module Rubyvis
+  # Returns the Rubyvis::Color for the specified color format string. Colors
+  # may have an associated opacity, or alpha channel. 
+  # Color formats are specified by CSS Color Modular Level 3, 
+  # using either in RGB or HSL color space. For example:<ul>
+  #
+  # <li>#f00 // #rgb
+  # <li>#ff0000 // #rrggbb
+  # <li>rgb(255, 0, 0)
+  # <li>rgb(100%, 0%, 0%)
+  # <li>hsl(0, 100%, 50%)
+  # <li>rgba(0, 0, 255, 0.5)
+  # <li>hsla(120, 100%, 50%, 1)
+  # </ul>
+  #
+  # The SVG 1.0 color keywords names are also supported, such as "aliceblue"
+  # and "yellowgreen". The "transparent" keyword is supported for fully-
+  # transparent black.
+  #
+  # <p>If the <tt>format</tt> argument is already an instance of <tt>Color</tt>,
+  # the argument is returned with no further processing.
+  #
+  # * see <a href="http://www.w3.org/TR/SVG/types.html#ColorKeywords">SVG color
+  # keywords</a>
+  # * see <a href="http://www.w3.org/TR/css3-color/">CSS3 color module</a>
+  #/
+  def self.color(format)
+    return format.rgb if format.respond_to? :rgb
+    if (format =~/([a-z]+)\((.*)\)/)
+      color_type,color_data=$1,$2
+      m2 = color_data.split(",")
+      a = 1
+      if ['hsla','rgba'].include? color_type
+        a = m2[3].to_f
+        return Color.transparent if (a==0)
+      end
+
+      if ['hsla','hsl'].include? color_type
+        h=m2[0].to_f
+        s=m2[1].to_f / 100.0
+        l=m2[2].to_f / 100.0
+        return Color::Hsl.new(h,s,l,a).rgb
+      end
+     
+      if ['rgba','rgb'].include? color_type
+        parse=lambda {|c|
+          (c[c.size-1,1]=='%') ? (c.to_f*2.55).round : c.to_i
+        }
+        r=parse.call(m2[0])
+        g=parse.call(m2[1])
+        b=parse.call(m2[2])
+        return Rubyvis.rgb(r,g,b,a)
+      end
+    end
+    
+    named = Rubyvis::Color::NAMES[format.to_sym]
+
+
+    return Rubyvis.color(named) if (named)
+
+    # Hexadecimal colors: #rgb and #rrggbb. */
+    if (format[0,1]== "#")
+      if (format.size == 4)
+        r = format[1,1]; r += r
+        g = format[2,1]; g +=g
+        b = format[3,1]; b +=b
+      elsif (format.size == 7)
+        r = format[1,2]
+        g = format[3,2]
+        b = format[5,2]
+      end
+      return Rubyvis.rgb(r.to_i(16), g.to_i(16), b.to_i(16), 1)
+    end
+
+    # Otherwise, pass-through unsupported colors. */
+    return Rubyvis::Color.new(format, 1);
+  end
+  # Constructs a new RGB color with the specified channel values.
+  def self.rgb(r,g,b,a=1)
+    Rubyvis::Color::Rgb.new(r,g,b,a)
+  end
+  def self.hsl(h,s,l,a=1)
+    Rubyvis::Color::Hsl.new(h,s,l,a)
+  end
+  # Represents an abstract (possibly translucent) color. The color is
+  # divided into two parts: the <tt>color</tt> attribute, an opaque color format
+  # string, and the <tt>opacity</tt> attribute, a float in [0, 1]. The color
+  # space is dependent on the implementing class; all colors support the
+  # Color.rgb() method to convert to RGB color space for interpolation.
+  class Color
+    
+    # Association between names and colors
+    NAMES={
+        :aliceblue=>"#f0f8ff",
+        :antiquewhite=>"#faebd7",
+        :aqua=>"#00ffff",
+        :aquamarine=>"#7fffd4",
+        :azure=>"#f0ffff",
+        :beige=>"#f5f5dc",
+        :bisque=>"#ffe4c4",
+        :black=>"#000000",
+        :blanchedalmond=>"#ffebcd",
+        :blue=>"#0000ff",
+        :blueviolet=>"#8a2be2",
+        :brown=>"#a52a2a",
+        :burlywood=>"#deb887",
+        :cadetblue=>"#5f9ea0",
+        :chartreuse=>"#7fff00",
+        :chocolate=>"#d2691e",
+        :coral=>"#ff7f50",
+        :cornflowerblue=>"#6495ed",
+        :cornsilk=>"#fff8dc",
+        :crimson=>"#dc143c",
+        :cyan=>"#00ffff",
+        :darkblue=>"#00008b",
+        :darkcyan=>"#008b8b",
+        :darkgoldenrod=>"#b8860b",
+        :darkgray=>"#a9a9a9",
+        :darkgreen=>"#006400",
+        :darkgrey=>"#a9a9a9",
+        :darkkhaki=>"#bdb76b",
+        :darkmagenta=>"#8b008b",
+        :darkolivegreen=>"#556b2f",
+        :darkorange=>"#ff8c00",
+        :darkorchid=>"#9932cc",
+        :darkred=>"#8b0000",
+        :darksalmon=>"#e9967a",
+        :darkseagreen=>"#8fbc8f",
+        :darkslateblue=>"#483d8b",
+        :darkslategray=>"#2f4f4f",
+        :darkslategrey=>"#2f4f4f",
+        :darkturquoise=>"#00ced1",
+        :darkviolet=>"#9400d3",
+        :deeppink=>"#ff1493",
+        :deepskyblue=>"#00bfff",
+        :dimgray=>"#696969",
+        :dimgrey=>"#696969",
+        :dodgerblue=>"#1e90ff",
+        :firebrick=>"#b22222",
+        :floralwhite=>"#fffaf0",
+        :forestgreen=>"#228b22",
+        :fuchsia=>"#ff00ff",
+        :gainsboro=>"#dcdcdc",
+        :ghostwhite=>"#f8f8ff",
+        :gold=>"#ffd700",
+        :goldenrod=>"#daa520",
+        :gray=>"#808080",
+        :green=>"#008000",
+        :greenyellow=>"#adff2f",
+        :grey=>"#808080",
+        :honeydew=>"#f0fff0",
+        :hotpink=>"#ff69b4",
+        :indianred=>"#cd5c5c",
+        :indigo=>"#4b0082",
+        :ivory=>"#fffff0",
+        :khaki=>"#f0e68c",
+        :lavender=>"#e6e6fa",
+        :lavenderblush=>"#fff0f5",
+        :lawngreen=>"#7cfc00",
+        :lemonchiffon=>"#fffacd",
+        :lightblue=>"#add8e6",
+        :lightcoral=>"#f08080",
+        :lightcyan=>"#e0ffff",
+        :lightgoldenrodyellow=>"#fafad2",
+        :lightgray=>"#d3d3d3",
+        :lightgreen=>"#90ee90",
+        :lightgrey=>"#d3d3d3",
+        :lightpink=>"#ffb6c1",
+        :lightsalmon=>"#ffa07a",
+        :lightseagreen=>"#20b2aa",
+        :lightskyblue=>"#87cefa",
+        :lightslategray=>"#778899",
+        :lightslategrey=>"#778899",
+        :lightsteelblue=>"#b0c4de",
+        :lightyellow=>"#ffffe0",
+        :lime=>"#00ff00",
+        :limegreen=>"#32cd32",
+        :linen=>"#faf0e6",
+        :magenta=>"#ff00ff",
+        :maroon=>"#800000",
+        :mediumaquamarine=>"#66cdaa",
+        :mediumblue=>"#0000cd",
+        :mediumorchid=>"#ba55d3",
+        :mediumpurple=>"#9370db",
+        :mediumseagreen=>"#3cb371",
+        :mediumslateblue=>"#7b68ee",
+        :mediumspringgreen=>"#00fa9a",
+        :mediumturquoise=>"#48d1cc",
+        :mediumvioletred=>"#c71585",
+        :midnightblue=>"#191970",
+        :mintcream=>"#f5fffa",
+        :mistyrose=>"#ffe4e1",
+        :moccasin=>"#ffe4b5",
+        :navajowhite=>"#ffdead",
+        :navy=>"#000080",
+        :oldlace=>"#fdf5e6",
+        :olive=>"#808000",
+        :olivedrab=>"#6b8e23",
+        :orange=>"#ffa500",
+        :orangered=>"#ff4500",
+        :orchid=>"#da70d6",
+        :palegoldenrod=>"#eee8aa",
+        :palegreen=>"#98fb98",
+        :paleturquoise=>"#afeeee",
+        :palevioletred=>"#db7093",
+        :papayawhip=>"#ffefd5",
+        :peachpuff=>"#ffdab9",
+        :peru=>"#cd853f",
+        :pink=>"#ffc0cb",
+        :plum=>"#dda0dd",
+        :powderblue=>"#b0e0e6",
+        :purple=>"#800080",
+        :red=>"#ff0000",
+        :rosybrown=>"#bc8f8f",
+        :royalblue=>"#4169e1",
+        :saddlebrown=>"#8b4513",
+        :salmon=>"#fa8072",
+        :sandybrown=>"#f4a460",
+        :seagreen=>"#2e8b57",
+        :seashell=>"#fff5ee",
+        :sienna=>"#a0522d",
+        :silver=>"#c0c0c0",
+        :skyblue=>"#87ceeb",
+        :slateblue=>"#6a5acd",
+        :slategray=>"#708090",
+        :slategrey=>"#708090",
+        :snow=>"#fffafa",
+        :springgreen=>"#00ff7f",
+        :steelblue=>"#4682b4",
+        :tan=>"#d2b48c",
+        :teal=>"#008080",
+        :thistle=>"#d8bfd8",
+        :tomato=>"#ff6347",
+        :turquoise=>"#40e0d0",
+        :violet=>"#ee82ee",
+        :wheat=>"#f5deb3",
+        :white=>"#ffffff",
+        :whitesmoke=>"#f5f5f5",
+        :yellow=>"#ffff00",
+        :yellowgreen=>"#9acd32",
+      }
+    
+    
+    # An opaque color format string, such as "#f00".
+    attr_reader :color
+    # The opacity, a float in [0, 1].
+    attr_reader :opacity
+    
+    # Constructs a color with the specified color format string and opacity. This
+    # constructor should not be invoked directly; use Rubyvis.color instead.
+    def initialize(color,opacity)
+      @color=color
+      @opacity=opacity
+    end
+    # Returns a new color that is a brighter version of this color. The behavior of
+    # this method may vary slightly depending on the underlying color space.
+    # Although brighter and darker are inverse operations, the results of a series
+    # of invocations of these two methods might be inconsistent because of rounding
+    # errors.
+    # * @param [k] {number} an optional scale factor; defaults to 1.
+    def brighter(k)
+      self.rgb.brighter(k)
+    end
+    
+    # Returns a new color that is a brighter version of this color. The behavior of
+    # this method may vary slightly depending on the underlying color space.
+    # Although brighter and darker are inverse operations, the results of a series
+    # of invocations of these two methods might be inconsistent because of rounding
+    # errors.
+    #
+    # * @param [k] {number} an optional scale factor; defaults to 1.
+    def darker(k)
+      self.rgb.darker(k)
+    end
+    
+    def self.transparent
+      Rubyvis.rgb(0,0,0,0)
+    end
+    # Represents a color in RGB space.
+    class Rgb < Color
+      # The red channel, an integer in [0, 255].
+      attr_reader :r
+      # The blue channel, an integer in [0, 255].
+      attr_reader :b
+      # The green channel, an integer in [0, 255].
+      attr_reader :g
+      # The alpha channel, a float in [0, 1].
+      attr_reader :a
+      # Constructs a new RGB color with the specified channel values.
+      def initialize(r,g,b,a)
+        @r=r
+        @b=b
+        @g=g
+        @a=a
+        @opacity=a
+        @color= @a > 0 ? "rgb(#{r.to_i},#{g.to_i},#{b.to_i})" : "none"
+      end
+      def ==(v)
+        self.class==v.class and @r==v.r and @b==v.b and @g==v.g and @a==v.a
+      end
+      
+      # Constructs a new RGB color with the same green, blue and alpha channels
+      # as this color, with the specified red channel.
+      def red(r1)
+        Rubyvis.rgb(r1,g,b,a)
+      end
+      # Constructs a new RGB color with the same red, blue and alpha channels
+      # as this color, with the specified green channel.
+      def green(g1)
+        Rubyvis.rgb(r,g1,b,a)
+      end
+      # Constructs a new RGB color with the same red, green and alpha channels
+      # as this color, with the specified blue channel.
+      def blue(b1)
+        Rubyvis.rgb(r,g,b1,a)
+      end
+      # Constructs a new RGB color with the same red, green and blue channels as this
+      # color, with the specified alpha channel.
+      
+      def alpha(a1)
+        Rubyvis.rgb(r,g,b,a1)
+      end
+      # Returns the RGB color equivalent to this color. This method is abstract and  must be implemented by subclasses.
+      def rgb
+        self
+      end
+      # Returns a new color that is a brighter version of this color. This method
+      # applies an arbitrary scale factor to each of the three RGB components of this
+      # color to create a brighter version of this color. Although brighter and
+      # darker are inverse operations, the results of a series of invocations of
+      # these two methods might be inconsistent because of rounding errors.
+      def brighter(k=1)
+        k = 0.7**k
+        i = 30
+        r=self.r
+        g=self.g
+        b=self.b
+        return Rubyvis.rgb(i, i, i, a) if (!r and !g and !b) 
+        r = i if (r and (r < i)) 
+        g = i if (g and (g < i)) 
+        b = i if (b and (b < i))
+        Rubyvis.rgb(
+          [255, (r/k).floor].min,
+          [255, (g/k).floor].min,
+          [255, (b/k).floor].min,
+        a)
+      end
+      # Returns a new color that is a darker version of this color. This method
+      # applies an arbitrary scale factor to each of the three RGB components of this
+      # color to create a darker version of this color. Although brighter and darker
+      # are inverse operations, the results of a series of invocations of these two
+      # methods might be inconsistent because of rounding errors.
+      def darker(k=1)
+        k = 0.7 ** k
+        Rubyvis.rgb(
+          [0, (k * r).floor].max,
+          [0, (k * g).floor].max,
+          [0, (k * b).floor].max,
+          a)
+      end
+      
+      def to_s
+        @color
+      end
+    end
+    # Represents a color in HSL space.
+    class Hsl < Color
+      # The hue, an integer in [0, 360].
+      attr_accessor :h
+      # The saturation, a float in [0, 1].
+      attr_accessor :s
+      # The lightness, a float in [0, 1].
+      attr_accessor :l
+      # The opacity, a float in [0, 1].
+      attr_accessor :a
+      
+      def initialize(h,s,l,a)
+        c="hsl(#{h},#{s * 100}%,#{l * 100}%)"
+        super(c,a)
+        @h=h
+        @s=s
+        @l=l
+        @a=a
+      end
+      def ==(v)
+        self.class==v.class and @h==v.h and @s==v.s and @l==v.l and @a==v.a
+      end
+      
+      # Returns the RGB color equivalent to this HSL color.
+      def rgb
+        h = self.h
+        s = self.s
+        l = self.l
+        # Some simple corrections for h, s and l. */
+        h = h % 360
+        h += 360 if (h < 0)
+        s = [0, [s, 1].min].max
+        l = [0, [l, 1].min].max
+        
+        # From FvD 13.37, CSS Color Module Level 3 
+        m2 = (l <= 0.5) ? (l * (1 + s)) : (l + s - l * s)
+        m1 = 2 * l - m2
+        v=lambda {|h1|
+          if (h1 > 360)
+            h1 -= 360
+          elsif (h1 < 0)
+             h1 += 360
+          end
+          
+          
+          return m1 + (m2 - m1) * h1 / 60.0 if (h1 < 60.0)
+          return m2 if (h1 < 180.0) 
+          return m1 + (m2 - m1) * (240.0 - h1) / 60.0 if (h1 < 240.0)
+          return m1
+        }
+        
+        vv=lambda {|h1| (v.call(h1) * 255).round}
+        Rubyvis.rgb(vv.call(h + 120), vv.call(h), vv.call(h - 120), a)
+       
+      end
+    end
+
+    
+    
+  end
+end
diff --git a/lib/rubyvis/color/colors.rb b/lib/rubyvis/color/colors.rb
new file mode 100644
index 0000000..c3cbe8f
--- /dev/null
+++ b/lib/rubyvis/color/colors.rb
@@ -0,0 +1,136 @@
+module Rubyvis
+  #
+  # :section: colors/Ramp.js
+  
+  
+  # Returns a linear color ramp from the specified <tt>start</tt> color to the
+  # specified <tt>end</tt> color. The color arguments may be specified either as
+  # <tt>string</tt>s or as Rubyvis::Color. This is equivalent to:
+  #
+  # <pre>    pv.Scale.linear().domain(0, 1).range(...)</pre>  
+  def self.ramp(*arguments)
+    #start, _end, dummy = arguments
+    scale = Rubyvis.Scale.linear
+    scale.range(*arguments)
+    scale
+  end
+  
+  # :section: colors/Colors.js
+  
+  # Alias for Rubyvis::Colors
+  def self.Colors
+    Rubyvis::Colors
+  end
+  
+  # Returns a new categorical color encoding using the specified colors.  The
+  # arguments to this method are an array of colors; see Rubyvis.color(). For
+  # example, to create a categorical color encoding using the <tt>species</tt>
+  # attribute:
+  #
+  # <pre>Rubyvis.colors("red", "green", "blue").by(lambda{|d| d.species})</pre>
+  #
+  # The result of this expression can be used as a fill- or stroke-style
+  # property. This assumes that the data's <tt>species</tt> attribute is a
+  # string.
+  #
+  def self.colors(*args)
+    scale=Rubyvis::Scale.ordinal
+    scale.range(*args)
+    scale
+  end
+  
+  # A collection of standard color palettes for categorical encoding.
+  module Colors
+    
+    # Returns a new 10-color scheme. The arguments to this constructor are
+    # optional, and equivalent to calling Rubyvis::Scale::Ordinal.domain. The
+    # following colors are used:
+    #
+    # <div style="background:#1f77b4;">#1f77b4</div>
+    # <div style="background:#ff7f0e;">#ff7f0e</div>
+    # <div style="background:#2ca02c;">#2ca02c</div>
+    # <div style="background:#d62728;">#d62728</div>
+    # <div style="background:#9467bd;">#9467bd</div>
+    # <div style="background:#8c564b;">#8c564b</div>
+    # <div style="background:#e377c2;">#e377c2</div>
+    # <div style="background:#7f7f7f;">#7f7f7f</div>
+    # <div style="background:#bcbd22;">#bcbd22</div>
+    # <div style="background:#17becf;">#17becf</div>
+    def self.category10(*arguments)
+      scale = Rubyvis.colors(
+      "#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd",
+      "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf")
+      scale.domain(*arguments) if arguments.size>0
+      scale
+    end
+    
+    # Returns a new alternative 19-color scheme. The arguments to this constructor
+    # are optional, and equivalent to calling
+    # Rubyvis::Scale::Ordinal.domain. The following colors are used:
+    #
+    # <div style="background:#9c9ede;">#9c9ede</div>
+    # <div style="background:#7375b5;">#7375b5</div>
+    # <div style="background:#4a5584;">#4a5584</div>
+    # <div style="background:#cedb9c;">#cedb9c</div>
+    # <div style="background:#b5cf6b;">#b5cf6b</div>
+    # <div style="background:#8ca252;">#8ca252</div>
+    # <div style="background:#637939;">#637939</div>
+    # <div style="background:#e7cb94;">#e7cb94</div>
+    # <div style="background:#e7ba52;">#e7ba52</div>
+    # <div style="background:#bd9e39;">#bd9e39</div>
+    # <div style="background:#8c6d31;">#8c6d31</div>
+    # <div style="background:#e7969c;">#e7969c</div>
+    # <div style="background:#d6616b;">#d6616b</div>
+    # <div style="background:#ad494a;">#ad494a</div>
+    # <div style="background:#843c39;">#843c39</div>
+    # <div style="background:#de9ed6;">#de9ed6</div>
+    # <div style="background:#ce6dbd;">#ce6dbd</div>
+    # <div style="background:#a55194;">#a55194</div>
+    # <div style="background:#7b4173;">#7b4173</div>
+    def self.category19(*arguments)
+      scale = Rubyvis.colors(
+      "#9c9ede", "#7375b5", "#4a5584", "#cedb9c", "#b5cf6b",
+      "#8ca252", "#637939", "#e7cb94", "#e7ba52", "#bd9e39",
+      "#8c6d31", "#e7969c", "#d6616b", "#ad494a", "#843c39",
+      "#de9ed6", "#ce6dbd", "#a55194", "#7b4173")
+      scale.domain(*arguments) if arguments.size>0
+      scale
+    end
+    
+
+    # Returns a new 20-color scheme. The arguments to this constructor are
+    # optional, and equivalent to calling Rubyvis::Scale::Ordinal.domain. The
+    # following colors are used:
+    #
+    # <div style="background:#1f77b4;">#1f77b4</div>
+    # <div style="background:#aec7e8;">#aec7e8</div>
+    # <div style="background:#ff7f0e;">#ff7f0e</div>
+    # <div style="background:#ffbb78;">#ffbb78</div>
+    # <div style="background:#2ca02c;">#2ca02c</div>
+    # <div style="background:#98df8a;">#98df8a</div>
+    # <div style="background:#d62728;">#d62728</div>
+    # <div style="background:#ff9896;">#ff9896</div>
+    # <div style="background:#9467bd;">#9467bd</div>
+    # <div style="background:#c5b0d5;">#c5b0d5</div>
+    # <div style="background:#8c564b;">#8c564b</div>
+    # <div style="background:#c49c94;">#c49c94</div>
+    # <div style="background:#e377c2;">#e377c2</div>
+    # <div style="background:#f7b6d2;">#f7b6d2</div>
+    # <div style="background:#7f7f7f;">#7f7f7f</div>
+    # <div style="background:#c7c7c7;">#c7c7c7</div>
+    # <div style="background:#bcbd22;">#bcbd22</div>
+    # <div style="background:#dbdb8d;">#dbdb8d</div>
+    # <div style="background:#17becf;">#17becf</div>
+    # <div style="background:#9edae5;">#9edae5</div>
+
+    def self.category20(*arguments)
+      scale = Rubyvis.colors(
+      "#1f77b4", "#aec7e8", "#ff7f0e", "#ffbb78", "#2ca02c",
+      "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5",
+      "#8c564b", "#c49c94", "#e377c2", "#f7b6d2", "#7f7f7f",
+      "#c7c7c7", "#bcbd22", "#dbdb8d", "#17becf", "#9edae5")
+      scale.domain(*arguments) if arguments.size>0
+      scale
+    end
+  end
+end
diff --git a/lib/rubyvis/dom.rb b/lib/rubyvis/dom.rb
new file mode 100644
index 0000000..c4946e1
--- /dev/null
+++ b/lib/rubyvis/dom.rb
@@ -0,0 +1,342 @@
+module Rubyvis
+  # Returns a Rubyvis::Dom operator for the given map. This is a convenience
+  # factory method, equivalent to Rubyvis::Dom.new(map). To apply the operator
+  # and retrieve the root node, call Rubyvis::Dom.root() to retrieve all nodes
+  # flattened, use Rubyvis::Dom.nodes
+  #
+  # @see pv.Dom
+  # @param map a map from which to construct a DOM.
+  # @returns {pv.Dom} a DOM operator for the specified map.
+  def self.dom(map) 
+    Rubyvis::Dom.new(map)
+  end
+
+  # Constructs a DOM operator for the specified map. This constructor should not
+  # be invoked directly; use {@link pv.dom} instead.
+  #
+  # @class Represets a DOM operator for the specified map. This allows easy
+  # transformation of a hierarchical JavaScript object (such as a JSON map) to a
+  # W3C Document Object Model hierarchy. For more information on which attributes
+  # and methods from the specification are supported, see {@link pv.Dom.Node}.
+  #
+  # <p>Leaves in the map are determined using an associated <i>leaf</i> function;
+  # see {@link #leaf}. By default, leaves are any value whose type is not
+  # "object", such as numbers or strings.
+  #
+  # @param map a map from which to construct a DOM.
+  class Dom
+    def initialize(map)
+      @_map=map
+      @leaf=lambda {|n| !n.respond_to? :each }
+    end
+    # Sets or gets the leaf function for this DOM operator. The leaf function
+    # identifies which values in the map are leaves, and which are internal nodes.
+    # By default, objects are considered internal nodes, and primitives (such as
+    # numbers and strings) are considered leaves.
+    #
+    # @param {function} f the new leaf function.
+    # @returns the current leaf function, or <tt>this</tt>.    
+    def leaf(f=nil)
+      if !f.nil?
+        @leaf=f
+        self
+      end
+      @leaf
+    end
+    
+    def root_recurse(map)
+      n = Rubyvis::Dom::Node.new
+      map.each {|k,v|
+        n.append_child(@leaf.call(v) ? Rubyvis::Dom::Node.new(v) : root_recurse(v)).node_name = k
+      }
+      return n
+    end
+    
+    # Applies the DOM operator, returning the root node.
+    def root(node_name=nil)
+      root=root_recurse(@_map)
+      root.node_name=node_name
+      root
+    end
+    
+   # Applies the DOM operator, returning the array of all nodes in preorder
+   # traversal.
+   # @returns {array} the array of nodes in preorder traversal.
+   def nodes
+     self.root.nodes
+   end
+   
+   def self.Node(value)
+     Node.new(value)
+   end
+   # Represents a <tt>Node</tt> in the W3C Document Object Model.
+    class Node
+      # The node name. When generated from a map, the node name corresponds to the
+      # key at the given level in the map. Note that the root node has no associated
+      # key, and thus has an undefined node name (and no <tt>parentNode</tt>).
+      attr_accessor :node_name
+      
+      # The node value. When generated from a map, node value corresponds to 
+      # the leaf value for leaf nodes, and is undefined for internal nodes.
+      attr_accessor :node_value
+      
+      # The array of child nodes. This array is empty for leaf nodes. An easy way to
+      # check if child nodes exist is to query <tt>firstChild</tt>.    
+      attr_accessor :child_nodes
+      attr_accessor :parent_node
+      # The first child, which is null for leaf nodes.
+      
+      attr_accessor :first_child
+      attr_accessor :last_child
+      attr_accessor :previous_sibling
+      attr_accessor :next_sibling
+      
+      attr_accessor :index
+      attr_accessor :link_degree
+      attr_accessor :depth
+      attr_accessor :dx
+      attr_accessor :dy
+      attr_accessor :x
+      attr_accessor :y
+      attr_accessor :size
+      
+      attr_accessor :min_breadth
+      attr_accessor :max_breadth
+      attr_accessor :breadth
+      attr_accessor :min_depth
+      attr_accessor :max_depth
+      
+      attr_accessor :mid_angle
+      attr_accessor :angle
+      attr_accessor :start_angle
+      attr_accessor :outer_radius
+      attr_accessor :inner_radius
+      attr_accessor :radius      
+      attr_accessor :_p
+      attr_accessor :n
+
+      ##
+      # Created for Tree
+      
+      attr_accessor :ancestor, :prelim, :mod, :change, :shift, :number, :thread
+      
+      
+      # Constructs a DOM node for the specified value. Instances of this class are
+      # not typically created directly; instead they are generated from a JavaScript 
+      # map using the {@link pv.Dom} operator.
+      def initialize(value=nil)
+        @node_value = value
+        @child_nodes=[]
+        @parent_node=nil
+        @first_child=nil
+        @last_child=nil
+        @previous_sibling=nil
+        @next_sibling=nil
+        
+      end
+      # Removes the specified child node from this node.
+      def remove_child(n)
+        i=@child_nodes.index n
+        raise "child not found" if i.nil?
+        @child_nodes.delete_at i
+        if n.previous_sibling
+         n.previous_sibling.next_sibling=n.next_sibling 
+        else
+          @first_child=n.next_sibling
+        end
+        if n.next_sibling
+         n.next_sibling.previous_sibling=n.previous_sibling 
+        else
+         @last_child=n.previous_sibling
+        end
+        n.next_sibling=nil
+        n.previous_sibling=nil
+        n.parent_node=nil
+        n
+      end
+      
+      # Appends the specified child node to this node. If the specified child is
+      # already part of the DOM, the child is first removed before being added to
+      # this node.
+      def append_child(n)
+        if n.parent_node
+         n.parent_node.remove_child(n)
+        end
+        n.parent_node=self
+        n.previous_sibling=last_child
+        if self.last_child
+          @last_child.next_sibling = n
+        else
+          @first_child=n
+        end
+        @last_child=n
+        child_nodes.push(n)
+        n
+      end
+      
+      # Inserts the specified child <i>n</i> before the given reference child
+      # <i>r</i> of this node. If <i>r</i> is null, this method is equivalent to
+      # {@link #appendChild}. If <i>n</i> is already part of the DOM, it is first
+      # removed before being inserted.
+      #
+      # @throws Error if <i>r</i> is non-null and not a child of this node.
+      # @returns {pv.Dom.Node} the inserted child.
+      def insert_before(n, r)
+        return append_child(n) if !r
+        i=@child_nodes.index r
+        raise "child not found" if i.nil?
+        n.parent_node.remove_child(n) if n.parent_node
+        n.parent_node=self
+        n.next_sibling=r
+        n.previous_sibling = r.previous_sibling
+        if r.previous_sibling
+          r.previous_sibling.next_sibling=n
+          r.previous_sibling=n
+        else
+          @last_child=n if r==@last_child
+          @first_child=n
+        end
+        @child_nodes = @child_nodes[0,i] + [n] + @child_nodes[i, child_nodes.size-i]
+        n
+      end
+      # Replaces the specified child <i>r</i> of this node with the node <i>n</i>. If
+      # <i>n</i> is already part of the DOM, it is first removed before being added.
+      
+      def replace_child(n,r)
+        i=child_nodes.index r
+        raise "child not found" if i.nil?
+        n.parent_node.remove_child(n) if n.parent_node
+        n.parent_node=self
+        n.next_sibling=r.next_sibling
+        n.previous_sibling=r.previous_sibling
+        if r.previous_sibling
+          r.previous_sibling.next_sibling=n
+        else
+          @first_child=n
+        end
+        if r.next_sibling
+          r.next_sibling.previous_sibling=n
+        else
+          @last_child=n
+        end
+        
+        @child_nodes[i]=n
+        r
+      end
+      
+      def visit_visit(n,i,block,moment)
+        block.call(n,i) if moment==:before
+        c=n.first_child
+        while c
+          visit_visit(c,i+1, block,moment)
+          c=c.next_sibling
+        end
+        block.call(n,i) if moment==:after
+      end
+      private :visit_visit
+      # Yield block on each child
+      # Replaces the javascript formula
+      #   for (var c = o.first_child; c; c = c.nextSibling)
+      def each_child
+        c=@first_child
+        while c
+          yield c
+          c=c.next_sibling
+        end
+      end
+      # Visits each node in the tree in preorder traversal, applying the specified
+      # proc <i>block</i>. The arguments to the function are:<ol>
+      #
+      # <li>The current node.
+      # <li>The current depth, starting at 0 for the root node.</ol>
+      
+      def visit_before(f=nil,&block)
+        block=f unless f.nil?
+        raise "Should pass a Proc" if block.nil?
+        visit_visit(self,0,block, :before)
+      end
+      # Visits each node in the tree in postorder traversal, applying the specified
+      # function <i>f</i>. The arguments to the function are:<ol>
+      #
+      # <li>The current node.
+      # <li>The current depth, starting at 0 for the root node.</ol>    
+      def visit_after(f=nil,&block)
+        block=f unless f.nil?
+        raise "Should pass a Proc" if block.nil?
+        visit_visit(self,0,block, :after)
+      end
+      
+      
+      # Sorts child nodes of this node, and all descendent nodes recursively, using
+      # the specified comparator function <tt>f</tt>. The comparator function is
+      # passed two nodes to compare.
+      #
+      # <p>Note: during the sort operation, the comparator function should not rely
+      # on the tree being well-formed; the values of <tt>previousSibling</tt> and
+      # <tt>nextSibling</tt> for the nodes being compared are not defined during the
+      # sort operation.
+      #
+      # @param {function} f a comparator function.
+      # @returns this.
+      def sort(f_a=nil,&f)
+        f=f_a unless f_a.nil?
+        raise "Should pass a Proc" if f.nil?
+        if @first_child
+          @child_nodes.sort!(&f)
+          _p=@first_child = child_nodes[0]
+          _p.previous_sibling=nil
+          (1... at child_nodes.size).each {|i|
+            _p.sort(&f)
+            c=@child_nodes[i]
+            c.previous_sibling=_p
+            _p=_p.next_sibling=c
+          }
+          @last_child=_p
+          _p.next_sibling=nil
+          _p.sort(f)
+        end
+        self
+      end
+      # Reverses all sibling nodes.
+      def reverse
+        child_nodes=[]
+        visit_after {|n,dummy|
+        while(n.last_child) do
+          child_nodes.push(n.remove_child(n.last_child)) 
+        end
+        c=nil
+        while(c=child_nodes.pop)
+          n.insert_before(c,n.first_child)
+        end
+        }
+        self
+      end
+      def nodes_flatten(node,array)
+        array.push(node)
+        node.child_nodes.each {|n|
+        nodes_flatten(n,array)
+        }
+      end
+      private :nodes_flatten
+      def nodes
+        array=[]
+        nodes_flatten(self,array)
+        array
+      end
+    # toggle missing
+      def inspect
+        childs=@child_nodes.map{|e| e.inspect}.join(",")
+        "#<#{self.class} #{object_id.to_s(16)} (#{}), name: #{@node_name}, value: #{@node_value} child_nodes: [#{childs}]>"
+      end
+    end # End Node
+  end # End Dom
+  # Given a flat array of values, returns a simple DOM with each value wrapped by
+  # a node that is a child of the root node.  
+  def self.nodes(values)
+    root=Rubyvis::Dom::Node.new
+    values.each do |v,i|
+      root.append_child(Rubyvis::Dom::Node.new(v))
+    end
+    root.nodes()
+  end
+end
diff --git a/lib/rubyvis/flatten.rb b/lib/rubyvis/flatten.rb
new file mode 100644
index 0000000..640c3a4
--- /dev/null
+++ b/lib/rubyvis/flatten.rb
@@ -0,0 +1,126 @@
+module Rubyvis
+  # Returns a {@link pv.Flatten} operator for the specified map. This is a
+  # convenience factory method, equivalent to <tt>new pv.Flatten(map)</tt>.  
+  def self.flatten(map)
+    Flatten.new(map)
+  end
+  # Represents a flatten operator for the specified array. Flattening
+  # allows hierarchical maps to be flattened into an array. The levels in the
+  # input tree are specified by <i>key</i> functions.
+  #
+  # <p>For example, consider the following hierarchical data structure of Barley
+  # yields, from various sites in Minnesota during 1931-2:
+  #
+  # <pre>{ 1931: {
+  #     Manchuria: {
+  #       "University Farm": 27.00,
+  #       "Waseca": 48.87,
+  #       "Morris": 27.43,
+  #       ... },
+  #     Glabron: {
+  #       "University Farm": 43.07,
+  #       "Waseca": 55.20,
+  #       ... } },
+  #   1932: {
+  #     ... } }</pre>
+  #
+  # To facilitate visualization, it may be useful to flatten the tree into a
+  # tabular array:
+  #
+  # <pre>var array = pv.flatten(yields)
+  #     .key("year")
+  #     .key("variety")
+  #     .key("site")
+  #     .key("yield")
+  #     .array();</pre>
+  #
+  # This returns an array of object elements. Each element in the array has
+  # attributes corresponding to this flatten operator's keys:
+  #
+  # <pre>{ site: "University Farm", variety: "Manchuria", year: 1931, yield: 27 },
+  # { site: "Waseca", variety: "Manchuria", year: 1931, yield: 48.87 },
+  # { site: "Morris", variety: "Manchuria", year: 1931, yield: 27.43 },
+  # { site: "University Farm", variety: "Glabron", year: 1931, yield: 43.07 },
+  # { site: "Waseca", variety: "Glabron", year: 1931, yield: 55.2 }, ...</pre>
+  #
+  # <p>The flatten operator is roughly the inverse of the {@link pv.Nest} and
+  # {@link pv.Tree} operators.
+  #
+  class Flatten
+    def initialize(map)
+      @map=map
+      @keys=[]
+      @leaf=nil
+    end
+    # Flattens using the specified key function. Multiple keys may be added to the
+    # flatten; the tiers of the underlying tree must correspond to the specified
+    # keys, in order. The order of the returned array is undefined; however, you
+    # can easily sort it.
+    #
+    # @param {string} key the key name.
+    # @param {function} [f] an optional value map function.
+    # @returns {pv.Nest} this.
+    
+    def key(k, f=nil)
+      @keys.push(OpenStruct.new({:name=>k, :value=>f}))
+      @leaf=nil
+      self
+    end
+
+    # Flattens using the specified leaf function. This is an alternative to
+    # specifying an explicit set of keys; the tiers of the underlying tree 
+    # will be determined dynamically by recursing on the values, and the resulting keys will be stored in the entries +:keys+ attribute. The leaf function must return true for leaves, and false for internal nodes.
+    #
+    # @param {function} f a leaf function.
+    # @returns {pv.Nest} this.
+    def leaf(f)
+      @keys.clear
+      @leaf=f
+      self
+    end
+    def recurse(value,i)
+      if @leaf.call(value)
+        @entries.push({:keys=>@stack.dup, :value=>value})
+      else
+        value.each {|key,v|
+          @stack.push(key)
+          recurse(v, i+1)
+          @stack.pop
+        }
+      end
+    end
+    def visit(value,i)
+      if (i < @keys.size - 1)
+        value.each {|key,v|
+          @stack.push(key)
+          visit(v,i+1)
+          @stack.pop
+        }
+      else 
+        @entries.push(@stack+[value])
+      end
+    end
+    # Returns the flattened array. Each entry in the array is an object; each
+    # object has attributes corresponding to this flatten operator's keys.
+    #
+    # @returns an array of elements from the flattened map.
+    def array
+      @entries=[]
+      @stack=[]
+      if @leaf
+        recurse(@map,0)
+        return @entries
+      end
+      visit(@map,0)
+      @entries.map {|stack|
+        m={}
+        @keys.each_with_index {|k,i|
+          v=stack[i]
+          m[k.name]=k.value ? k.value.js_call(self,v) : v
+        }
+        m
+      }
+    end
+    alias :to_a :array
+  end
+end
diff --git a/lib/rubyvis/format.rb b/lib/rubyvis/format.rb
new file mode 100644
index 0000000..f4c9e22
--- /dev/null
+++ b/lib/rubyvis/format.rb
@@ -0,0 +1,19 @@
+module Rubyvis
+  def self.Format
+    Rubyvis::Format
+  end
+
+  module Format
+    def self.re(s)
+      s.gsub(/[\\\^\$\*\+\?\[\]\(\)\.\{\}]/, "\\$&")
+    end
+    def self.number
+      Format::Number.new
+    end
+    def self.date(pattern)
+      Format::Date.new(pattern)
+    end
+  end
+end
+require 'rubyvis/format/number'
+require 'rubyvis/format/date'
diff --git a/lib/rubyvis/format/date.rb b/lib/rubyvis/format/date.rb
new file mode 100644
index 0000000..7445992
--- /dev/null
+++ b/lib/rubyvis/format/date.rb
@@ -0,0 +1,25 @@
+require 'date'
+module Rubyvis
+  module Format
+    class Date
+      attr_reader :pattern
+      def initialize(pattern)
+        @pattern=pattern
+        #@pad=Rubyvis::Format.pad
+      end
+      def format(d)
+        d.strftime(pattern)
+      end
+      def format_lambda
+        pat=pattern
+        lambda {|d| 
+          d.strftime(pat)
+        }
+      end
+      def parse(s)
+        time=::DateTime.strptime(s, pattern)
+        Time.utc(time.year, time.month, time.day, time.hour, time.min, time.sec, 0)
+      end
+    end
+  end
+end
diff --git a/lib/rubyvis/format/number.rb b/lib/rubyvis/format/number.rb
new file mode 100644
index 0000000..ba1eb15
--- /dev/null
+++ b/lib/rubyvis/format/number.rb
@@ -0,0 +1,101 @@
+module Rubyvis
+  module Format
+    class Number
+      def initialize
+        @mini = 0
+        @maxi = Infinity # default maximum integer digits
+        @mins = 0.0 # mini, including group separators
+        @minf = 0.0 # default minimum fraction digits
+        @maxf = 0.0 # default maximum fraction digits
+        @maxk = 1 # 10^maxf
+        @padi = "0" # default integer pad
+        @padf = "0" # default fraction pad
+        @padg = true # whether group separator affects integer padding
+        @decimal = "." # default decimal separator
+        @group = "," # default group separator
+        @np = "\u2212" # default negative prefix
+        @ns = "" # default negative suffix
+      end
+      
+      
+      def to_proc
+        that=self
+        lambda {|*args|  args[0] ? that.format(args[0]) : nil }
+      end
+      #/** @private */
+      def format(x) 
+        
+        # /* Round the fractional part, and split on decimal separator. */
+        x = (x * @maxk).round.quo(@maxk) if (Infinity > @maxf)
+        x = (x.to_f-x.to_i==0) ? x.to_i : x.to_f
+        s = x.abs.to_s.split(".")
+        
+        #/* Pad, truncate and group the integral part. */
+        i = s[0]
+        
+        i = i[i.size- at maxi, i.size] if (i.size > @maxi) 
+        if (@padg and (i.size < @mini))
+          i = Array.new(@mini - i.size + 1).join(@padi) + i.to_s
+        end
+        
+        if (i.size > 3)
+          i = i.gsub(/\B(?=(?:\d{3})+(?!\d))/, @group)
+        end
+        
+        if (@padg=="" and (i.size < @mins))
+          i = Array.new(mins - i.size + 1).join(@padi) + i.to_s
+        end
+        
+        s[0] = x < 0 ? @np + i + @ns : i
+        
+        #/* Pad the fractional part. */
+        f = s[1].nil? ? "" : s[1]
+        if (f.size < @minf)
+          s[1] = f + Array.new(@minf - f.size + 1).join(@padf)
+        end
+        s.join(@decimal)
+      end
+
+      # Sets or gets the minimum and maximum number of fraction digits. The
+      # controls the number of decimal digits to display after the decimal
+      # separator for the fractional part of the number. 
+      # If the number of digits is smaller than the minimum, the digits 
+      # are padded; if the number of digits is
+      # larger, the fractional part is rounded, showing only the higher-order
+      # digits. The default range is [0, 0].
+      #
+      # If only one argument is specified to this method, this value is used as
+      # both the minimum and maximum number. If no arguments are specified, a
+      # two-element array is returned containing the minimum and the maximum.
+      #
+      # @function
+      # @name Rubyvis.Format.number.prototype.fractionDigits
+      # @param {number} [min] the minimum fraction digits.
+      # @param {number} [max] the maximum fraction digits.
+      # @returns {Rubyvis.Format.number} <tt>this</tt>, or the current fraction digits.
+      
+      def fraction_digits(min=nil,max=nil)
+        if (!min.nil?)
+          max||=min
+          @minf = min
+          @maxf = max
+          @maxk = 10**@maxf
+          return self
+        end
+        [@minf, @maxf]
+      end
+      
+      
+      def integer_digits(min=nil,max=nil)
+        if (!min.nil?)
+          max||=min
+          @mini=min
+          @maxi=max
+          @mins=@mini+(@mini/3.0).floor*@group.size 
+          return self
+        end
+        [@mini, @maxi]
+      end
+    end
+  end
+end
diff --git a/lib/rubyvis/histogram.rb b/lib/rubyvis/histogram.rb
new file mode 100644
index 0000000..68931fc
--- /dev/null
+++ b/lib/rubyvis/histogram.rb
@@ -0,0 +1,44 @@
+module Rubyvis
+  def self.histogram(data,f=nil)
+    Rubyvis::Histogram.new(data,f)
+  end
+  class Histogram
+    module Bin
+      attr_accessor :x, :dx, :y
+    end
+    attr_accessor :frequency
+    attr_reader :data
+    attr_reader :f
+    def initialize(data,f=nil)
+      @data=data
+      @f=f
+      @frequency=true
+    end
+    def bins(ticks=nil)
+      x=Rubyvis.map(data,f)
+      bins=[]
+      ticks||=Rubyvis::Scale.linear(x).ticks()
+      # Initialize the bins
+      (ticks.size-1).times {|i|
+        bin=bins[i]=[]
+        bin.extend Bin
+        bin.x=ticks[i]
+        bin.dx=ticks[i+1]-ticks[i]
+        bin.y=0
+      }
+      x.size.times {|i|
+        j=Rubyvis.search_index(ticks, x[i])-1
+        bin=bins[ [0,[bins.size-1,j].min].max]
+        bin.y+=1
+        bin.push(data[i])
+      }
+      if !@frequency
+        bins.each {|b|
+          b.y=b.y/x.size.to_f
+        }
+      end
+      bins
+    end
+    
+  end
+end
diff --git a/lib/rubyvis/internals.rb b/lib/rubyvis/internals.rb
new file mode 100644
index 0000000..f8e317f
--- /dev/null
+++ b/lib/rubyvis/internals.rb
@@ -0,0 +1,270 @@
+module Rubyvis
+  # :section: /pv-internals.js
+  @@id=0
+  # Returns a locally-unique positive id.
+  def self.id
+    @@id+=1
+  end
+  # Return a proc wrapping specific constant
+  def self.functor(f)
+    (f.is_a? Proc) ? f : lambda {f}
+  end
+  ##
+  # :section: /data/Arrays.js
+  
+  ##
+  # A private variant of Array.map that supports the index property
+  # 
+  # :call-seq:
+  #   self.map(Array)
+  #   self.map(array,proc)
+  #
+  
+  def self.map(array, f=nil)
+    if f
+      array.size.times.map {|i|
+        o=o_index(i)
+        f.js_call(o, array[i])
+      }
+    else
+      array.dup
+    end
+  end
+  #
+  # Concatenates the specified array with itself <i>n</i> times. For example,
+  # +repeat([1, 2])+ returns [1, 2, 1, 2].
+  #
+  # * @param {array} a an array.
+  # * @param {number} [n] the number of times to repeat; defaults to two.
+  # * @returns {array} an array that repeats the specified array.
+  #
+  def self.repeat(array, n=2)
+    array*n
+  end
+  def self.cross(a,b)
+    array = [];
+    a.each {|x|
+      b.each {|y|
+        array.push([x,y])
+      }
+    }
+    array
+  end
+  def self.blend(arrays)
+    # I love Ruby expresivness
+    arrays.inject([]) {|ac,v| ac+v}
+  end
+  def self.transpose(matrix)
+    out=[]
+    matrix.size.times do |i|
+      matrix[i].size.times do |j|
+        out[j]||=Array.new
+        out[j][i]=matrix[i][j]
+      end
+    end
+    out
+  end
+  def self.normalize(array,f=nil)
+    norm=Rubyvis.map(array,f)
+    sum=Rubyvis.sum(norm)
+    norm.map {|x| x.quo(sum)}
+  end
+  def self.o_index(i)
+    OpenStruct.new :index=>i
+  end
+  def self.permute(array,indexes, f=nil)
+    f=Rubyvis.identity if f.nil?
+    indexes.map {|i| o=o_index(i); f.js_call(o, array[i])}
+  end
+  def self.numerate(keys, f=nil)
+    f=Rubyvis.identity if f.nil?
+    m = {}
+    keys.each_with_index {|x,i|
+      o=o_index(i)
+      m[f.js_call(o,x)]=i
+    }
+    m
+  end
+  def self.uniq(array, f=nil  )
+    self.map(array,f).uniq
+  end
+  def self.natural_order()
+    lambda {|a,b| a<=>b}
+  end
+  def self.reverse_order()
+    lambda {|a,b| -(a<=>b)}
+  end
+
+  def self.search(array, value, f=nil)
+    f = Rubyvis.identity if (f.nil?)
+    low = 0
+    high = array.size - 1;
+    while (low <= high)
+      mid = (low + high) >> 1
+      midValue = f.call(array[mid]);
+      if (midValue < value)
+        low = mid + 1;
+      elsif (midValue > value)
+        high = mid - 1;
+      else
+        return mid;
+      end
+    end
+    return -low - 1;
+  end
+  def self.search_index(array,value,f=nil)
+    i=Rubyvis.search(array,value,f)
+    (i < 0 ) ? (-i-1) : i;
+  end
+
+
+  # :section: /data/Numbers.js
+
+  def self.range(*arguments)
+    start, stop, step=arguments
+    if (arguments.size == 1)
+      stop = start
+      start = 0
+    end
+    step||= 1
+    raise "range must be finite" if ((stop.to_f - start.to_f) / step.to_f).infinite?
+    array = []
+    i = 0
+    stop = stop- (stop - start) * 1e-10 #// floating point precision!
+    j = start + step * i
+    if (step < 0)
+      while (j > stop)
+        array.push(j)
+        i+=1
+        j = start + step * i
+      end
+    else
+      while (j < stop)
+        array.push(j)
+        i+=1
+        j = start + step * i
+      end
+    end
+    array
+  end
+  def self.random(*arguments)
+    start,stop,step=arguments
+    if (arguments.size == 1)
+      stop = start;
+      start = 0;
+    end
+    step||= 1;
+    return step ? ((rand() * (stop - start).quo(step)).floor * step + start) : (rand() * (stop - start) + start);
+  end
+
+  def self.sum(array, f=nil)
+    if f.nil?
+      array.inject(0) {|ac, v| ac+v}
+    else
+      i=0
+      array.inject(0) {|ac,v|
+        o=o_index(i)
+        i+=1
+        ac+f.js_call(o, v)
+      }
+    end
+  end
+  def self.max(array, f=nil)
+    return array.size-1 if f==Rubyvis.index
+    f ? Rubyvis.map(array, f).max : array.max
+  end
+  def self.max_index(array,f=nil)
+    a2=Rubyvis.map(array,f)
+    max=a2.max
+    a2.index(max)
+  end
+
+  def self.min(array, f=nil)
+    return array.size-1 if f==Rubyvis.index
+    f ? Rubyvis.map(array, f).min : array.min
+  end
+  def self.min_index(array,f=nil)
+    a2=Rubyvis.map(array,f)
+    min=a2.min
+    a2.index(min)
+  end
+  def self.mean(array, f=nil)
+    Rubyvis.sum(array,f).quo(array.size)
+  end
+  def self.median(array,f=nil)
+    return (array.length - 1).quo(2) if (f == Rubyvis.index)
+    array = Rubyvis.map(array, f).sort
+    return array[array.size.quo(2).floor] if (array.length % 2>0)
+    i = array.size.quo(2);
+    return (array[i - 1] + array[i]).quo(2);
+  end
+  # Sum of square, really
+  def self.variance(array,f=nil)
+    return 0 if array.size==1 or array.uniq.size==1
+    ar=(f.nil?) ? array : Rubyvis.map(array,f)
+    mean=Rubyvis.mean(ar)
+    ar.inject(0) {|ac,v| ac+(v-mean)**2}
+  end
+  def self.deviation(array,f=nil)
+    Math::sqrt(self.variance(array,f) / (array.size.to_f-1))
+  end
+  def self.log(x,b)
+    Math::log(x).quo(Math::log(b))
+  end
+  def self.log_symmetric(x,b)
+    (x == 0) ? 0 : ((x < 0) ? -Rubyvis.log(-x, b) : Rubyvis.log(x, b));
+  end
+  def self.log_adjusted(x,b)
+    x if x.is_a? Float and !x.finite?
+    negative=x<0
+    x += (b - x) / b.to_f if (x < b)
+    negative ? -Rubyvis.log(x, b) : Rubyvis.log(x, b);
+  end
+  def self.log_floor(x,b)
+    (x>0)  ? b**(Rubyvis.log(x,b).floor) : b**(-(-Rubyvis.log(-x,b)).floor)
+  end
+  def self.log_ceil(x,b)
+    (x > 0) ? b ** (Rubyvis.log(x, b)).ceil : -(b ** -(-Rubyvis.log(-x, b)).ceil);
+  end
+  def self.radians(degrees)
+    (Math::PI/180.0)*degrees
+  end
+  def self.degrees(radians)
+    ((180.0) / Math::PI)*radians
+  end
+  # :section: /data/Objects.js
+  
+  def self.keys(map)
+    map.keys
+  end
+  
+  # Returns a map constructed from the specified <tt>keys</tt>, using the
+  # function <tt>f</tt> to compute the value for each key. The single argument to
+  # the value function is the key. The callback is invoked only for indexes of
+  # the array which have assigned values; it is not invoked for indexes which
+  # have been deleted or which have never been assigned values.
+  #
+  # <p>For example, this expression creates a map from strings to string length:
+  #
+  # <pre>pv.dict(["one", "three", "seventeen"], function(s) s.length)</pre>
+  #
+  # The returned value is <tt>{one: 3, three: 5, seventeen: 9}</tt>. Accessor
+  # functions can refer to <tt>this.index</tt>.
+  #
+  # * @param {array} keys an array.
+  # * @param {function} f a value function.
+  # * @returns a map from keys to values.
+
+  
+  def self.dict(keys, f)
+    m = {}
+    keys.size.times do |i|
+      unless keys[i].nil?
+        k=keys[i] 
+        o=o_index(i)
+        m[k]=f.js_call(o,k)
+      end
+    end
+    m
+  end
+end
diff --git a/lib/rubyvis/javascript_behaviour.rb b/lib/rubyvis/javascript_behaviour.rb
new file mode 100644
index 0000000..1f83d75
--- /dev/null
+++ b/lib/rubyvis/javascript_behaviour.rb
@@ -0,0 +1,78 @@
+class TrueClass
+  # Return 1
+  def to_i
+    1
+  end
+end
+class FalseClass
+  # Return 0
+  def to_i
+    0
+  end
+end
+
+# :stopdoc:
+unless Object.public_method_defined? :instance_exec
+  class Object
+    module InstanceExecHelper; end
+    include InstanceExecHelper
+    def instance_exec(*args, &block) # :nodoc:
+      begin
+        old_critical, Thread.critical = Thread.critical, true
+        n = 0
+        n += 1 while respond_to?(mname="__instance_exec#{n}")
+        InstanceExecHelper.module_eval{ define_method(mname, &block) }
+      ensure
+        Thread.critical = old_critical
+      end
+      begin
+        ret = send(mname, *args)
+      ensure
+        InstanceExecHelper.module_eval{ remove_method(mname) } rescue nil
+      end
+      ret
+    end
+  end
+end
+# :startdoc:
+
+# Add javascript-like +apply+ and +call+ methods to Proc,
+# called +js_apply+ and +js_call+, respectivly.
+class Proc
+  # Used on Rubyvis::Nest
+  attr_accessor :order # :nodoc:
+  
+  # Emulation of +apply+ javascript method.
+  # +apply+ has this signature
+  #   my_proc.apply(my_obj, args)
+  # where
+  # [+my_proc+] a proc
+  # [+my_obj+]  object inside proc is eval'ed
+  # [args]      array of arguments for proc
+  # 
+  # +apply+ on javascript is very flexible. Can accept more or less
+  # variables than explicitly defined parameters on lambda, so this
+  # method adds or remove elements according to lambda arity
+  #
+  def js_apply(obj,args)
+    arguments=args.dup
+    # Modify numbers of args to works with arity
+    min_args=self.arity > 0 ? self.arity : (-self.arity)-1
+    
+    if args.size > min_args and self.arity>0
+      arguments=arguments[0,self.arity]
+    elsif args.size < min_args
+      arguments+=[nil]*(min_args-args.size)
+    end
+    #puts "#{args}->#{arguments} (#{self.arity})"
+    if self.arity==0
+        obj.instance_exec(&self)
+    else
+      obj.instance_exec(*arguments, &self)
+    end
+  end
+  # Same as js_apply, but using explicit arguments
+  def js_call(obj, *args)
+    js_apply(obj,args)
+  end
+end
diff --git a/lib/rubyvis/layout.rb b/lib/rubyvis/layout.rb
new file mode 100644
index 0000000..92d6b21
--- /dev/null
+++ b/lib/rubyvis/layout.rb
@@ -0,0 +1,50 @@
+module Rubyvis
+  def self.Layout
+    Rubyvis::Layout
+  end
+  class Layout < Rubyvis::Panel
+    @properties=Panel.properties.dup
+    def build_properties(s,properties)      
+      layout_build_properties(s,properties)
+    end
+    def layout_build_properties(s,properties)
+      mark_build_properties(s, properties)
+    end
+    def layout_build_implied(s)      
+      panel_build_implied(s)
+    end
+    def self.attr_accessor_dsl(*attr)
+      attr.each  do |sym|
+        if sym.is_a? Array
+          name,func=sym
+        else
+          name=sym
+          func=nil
+        end
+        @properties[name]=true
+        self.property_method(name,false, func, self)
+
+        remove_method(name.to_s+"=") if public_method_defined? name.to_s+"="
+        
+        define_method(name.to_s + "=") {|v|
+          self.send(name,v)
+        }
+      end
+    end
+  end
+end
+
+require 'rubyvis/layout/stack'
+require 'rubyvis/layout/horizon'
+require 'rubyvis/layout/grid'
+require 'rubyvis/layout/network'
+require 'rubyvis/layout/hierarchy'
+require 'rubyvis/layout/tree'
+require 'rubyvis/layout/treemap'
+require 'rubyvis/layout/partition'
+require 'rubyvis/layout/cluster'
+require 'rubyvis/layout/indent'
+require 'rubyvis/layout/pack'
+require 'rubyvis/layout/arc'
+require 'rubyvis/layout/matrix'
+
diff --git a/lib/rubyvis/layout/arc.rb b/lib/rubyvis/layout/arc.rb
new file mode 100644
index 0000000..694888f
--- /dev/null
+++ b/lib/rubyvis/layout/arc.rb
@@ -0,0 +1,183 @@
+module Rubyvis
+  class Layout
+    # Alias for Rubyvis::Layout::Arc
+    def self.Arc
+      Rubyvis::Layout::Arc
+    end
+    
+    # Implements a layout for arc diagrams. An arc diagram is a network
+    # visualization with a one-dimensional layout of nodes, using circular arcs to
+    # render links between nodes. For undirected networks, arcs are rendering on a
+    # single side; this makes arc diagrams useful as annotations to other
+    # two-dimensional network layouts, such as rollup, matrix or table layouts. For
+    # directed networks, links in opposite directions can be rendered on opposite
+    # sides using <tt>directed(true)</tt>.
+    #
+    # <p>Arc layouts are particularly sensitive to node ordering; for best results,
+    # order the nodes such that related nodes are close to each other. A poor
+    # (e.g., random) order may result in large arcs with crossovers that impede
+    # visual processing. A future improvement to this layout may include automatic reordering using, e.g., spectral graph layout or simulated annealing.
+    #
+    # This visualization technique is related to that developed by  M. Wattenberg, {Arc Diagrams: Visualizing Structure in Strings}[http://www.research.ibm.com/visual/papers/arc-diagrams.pdf] in IEEE InfoVis, 2002.
+    # However, this implementation is limited to simple node-link networks, as
+    # opposed to structures with hierarchical self-similarity (such as strings).
+    # As with other network layouts, three mark prototypes are provided:<ul>
+    #
+    # <li><tt>node</tt> - for rendering nodes; typically a Rubyvis::Dot
+    # <li><tt>link</tt> - for rendering links; typically a Rubyvis::Line
+    # <li><tt>node_label</tt> - for rendering node labels; typically a Rubyvis::Label
+    #
+    # </ul>
+    # For more details on how this layout is structured and can be customized,
+    # see Rubyvis::Layout::Network
+    
+    class Arc < Network
+      @properties=Network.properties.dup
+      
+      attr_accessor :_interpolate # :nodoc:
+      attr_accessor :_directed    # :nodoc:
+      attr_accessor :_reverse     # :nodoc:
+      def initialize
+        super
+        @_interpolate=nil # cached interpolate
+        @_directed=nil # cached directed
+        @_reverse=nil # cached reverse
+        @_sort=nil
+        that=self
+        @link.data(lambda {|_p|
+            s=_p.source_node;t=_p.target_node
+            that._reverse != (that._directed or (s.breadth < t.breadth)) ? [s, t] : [t, s]
+        }).interpolate(lambda{ that._interpolate})
+      end
+      
+      def build_implied(s) # :nodoc:
+        return true if network_build_implied(s)
+        # Cached
+        
+        nodes = s.nodes
+        orient = s.orient
+        sort = @_sort
+        index = Rubyvis.range(nodes.size)
+        w = s.width
+        h = s.height
+        r = [w,h].min / 2.0 
+        # /* Sort the nodes. */
+        if (sort)
+          index.sort! {|a,b| sort.call(nodes[a],nodes[b])}
+        end
+        
+        
+        
+        #/** @private Returns the mid-angle, given the breadth. */
+        mid_angle=lambda do |b| 
+          case orient 
+            when "top"
+              -Math::PI / 2.0
+            when "bottom"
+              Math::PI / 2.0
+            when "left"
+              Math::PI
+            when "right"
+              0
+            when "radial"
+              (b - 0.25) * 2.0 * Math::PI
+          end
+        end
+        
+        # /** @private Returns the x-position, given the breadth. */
+        x= lambda do |b|
+          case orient 
+            when "top"
+              b * w
+            when "bottom"
+             b * w
+            when "left"
+            0;
+            when "right"
+            w;
+            when "radial"
+              w / 2.0 + r * Math.cos(mid_angle.call(b))
+          end
+        end
+        
+        # /** @private Returns the y-position, given the breadth. */
+        y=lambda do |b| 
+          case orient 
+          when "top"
+            0;
+          when "bottom"
+            h;
+          when "left"
+            b* h
+          when "right"
+            b * h
+          when "radial"
+            h / 2.0 + r * Math.sin(mid_angle.call(b))
+          end
+        end
+        
+        #/* Populate the x, y and mid-angle attributes. */
+        nodes.each_with_index do |nod, i|
+          n=nodes[index[i]]
+          n.breadth=(i+0.5) / nodes.size
+          b=n.breadth
+          n.x=x[b]
+          n.y=y[b]
+          n.mid_angle=mid_angle[b]
+        end        
+        
+        @_directed = s.directed
+        @_interpolate = s.orient == "radial" ? "linear" : "polar"
+        @_reverse = s.orient == "right" or s.orient == "top"
+        
+      end
+      
+      ##
+      # :attr: orient
+      # The orientation. The default orientation is "bottom", which means that nodes  will be positioned from bottom-to-top in the order they are specified in the
+      # <tt>nodes</tt> property. The following orientations are supported:<ul>
+      #
+      # <li>left - left-to-right.
+      # <li>right - right-to-left.
+      # <li>top - top-to-bottom.
+      # <li>bottom - bottom-to-top.
+      # <li>radial - radially, starting at 12 o'clock and proceeding clockwise.</ul>
+      
+      ##
+      # :attr: directed
+      # Whether this arc digram is directed (bidirectional); only applies to
+      # non-radial orientations. By default, arc digrams are undirected, such that
+      # all arcs appear on one side. If the arc digram is directed, then forward
+      # links are drawn on the conventional side (the same as as undirected
+      # links--right, left, bottom and top for left, right, top and bottom,
+      # respectively), while reverse links are drawn on the opposite side.
+      
+      attr_accessor_dsl :orient, :directed
+      # Default properties for arc layouts. By default, the orientation is "bottom".
+      def self.defaults
+        Arc.new.mark_extend(Network.defaults).
+          orient("bottom")
+      end
+      
+      # Specifies an optional sort function. The sort function follows the same
+      # comparator contract required by Rubyvis::Dom::Node.sort(). Specifying a sort
+      # function provides an alternative to sort the nodes as they are specified by
+      # the <tt>nodes</tt> property; the main advantage of doing this is that the
+      # comparator function can access implicit fields populated by the network
+      # layout, such as the <tt>link_degree</tt>.
+      #
+      # <p>Note that arc diagrams are particularly sensitive to order. This is
+      # referred to as the seriation problem, and many different techniques exist to
+      # find good node orders that emphasize clusters, such as spectral layout and
+      # simulated annealing.
+      def sort(f=nil,&block)
+        f||=block
+        @_sort=f
+        self
+      end
+      
+      
+    end
+  end
+end
+
diff --git a/lib/rubyvis/layout/cluster.rb b/lib/rubyvis/layout/cluster.rb
new file mode 100644
index 0000000..3b805c5
--- /dev/null
+++ b/lib/rubyvis/layout/cluster.rb
@@ -0,0 +1,203 @@
+module Rubyvis
+  class Layout
+    # Alias for Rubyvis::Layout::Cluster
+    def self.Cluster
+      Rubyvis::Layout::Cluster
+    end
+
+    # Implements a hierarchical layout using the cluster (or dendrogram)
+    # algorithm. This layout provides both node-link and space-filling
+    # implementations of cluster diagrams. In many ways it is similar to
+    # {@link pv.Layout.Partition}, except that leaf nodes are positioned at maximum
+    # depth, and the depth of internal nodes is based on their distance from their
+    # deepest descendant, rather than their distance from the root.
+    #
+    # <p>The cluster layout supports a "group" property, which if true causes
+    # siblings to be positioned closer together than unrelated nodes at the same
+    # depth. Unlike the partition layout, this layout does not support dynamic
+    # sizing for leaf nodes; all leaf nodes are the same size.
+    #
+    # <p>For more details on how to use this layout, see
+    # Rubyvis::Layout::Hierarchy.
+    #
+    # @see pv.Layout.Cluster.Fill
+    # @extends pv.Layout.Hierarchy
+    class Cluster < Hierarchy
+      include NodeLink
+      attr_accessor :interpolate
+       @properties=Hierarchy.properties.dup 
+        # Constructs a new, empty cluster layout. Layouts are not typically
+        # constructed directly; instead, they are added to an existing panel via
+        # {@link pv.Mark#add}.
+        attr_accessor :interpolate
+        
+      def initialize
+        super
+        @interpolate=nil
+        that=self
+        ## @private Cache layout state to optimize properties. #/
+        @link.interpolate {that.interpolate}
+      end
+      ##
+      # :attr: group
+      # The group parameter; defaults to 0, disabling grouping of siblings. If this
+      # parameter is set to a positive number (or true, which is equivalent to 1),
+      # then additional space will be allotted between sibling groups. In other
+      # words, siblings (nodes that share the same parent) will be positioned more
+      # closely than nodes at the same depth that do not share a parent.
+      #
+      # @type number
+      
+      ##
+      # :attr:orient 
+      #
+      # The orientation. The default orientation is "top", which means that the root
+      # node is placed on the top edge, leaf nodes appear on the bottom edge, and
+      # internal nodes are in-between. The following orientations are supported:<ul>
+      #
+      # <li>left - left-to-right.
+      # <li>right - right-to-left.
+      # <li>top - top-to-bottom.
+      # <li>bottom - bottom-to-top.
+      # <li>radial - radially, with the root at the center.</ul>
+      #
+      # @type string
+      
+      ##
+      # :attr: inner_radius
+      #
+      # The inner radius; defaults to 0. This property applies only to radial
+      # orientations, and can be used to compress the layout radially. Note that for
+      # the node-link implementation, the root node is always at the center,
+      # regardless of the value of this property; this property only affects internal
+      # and leaf nodes. For the space-filling implementation, a non-zero value of
+      # this property will result in the root node represented as a ring rather than
+      # a circle.
+      #
+      # @type number
+      
+      ##
+      # :attr: outer_radius
+      # The outer radius; defaults to fill the containing panel, based on the height
+      # and width of the layout. If the layout has no height and width specified, it
+      # will extend to fill the enclosing panel.
+      #
+      # @type number
+      
+      attr_accessor_dsl :group, :orient, :inner_radius, :outer_radius
+
+
+      
+      # Defaults for cluster layouts. The default group parameter is 0 and the
+      # default orientation is "top".
+      #
+      # @type pv.Layout.Cluster
+      def self.defaults
+        Cluster.new.mark_extend(Hierarchy.defaults).
+          group(0).
+          orient("top")
+      end
+      def build_implied(s)
+        cluster_build_implied(s)
+      end
+      def cluster_build_implied(s)
+        @interpolate=case s.orient
+          when /^(top|bottom)$/
+            'step-before'
+          when /^(left|right)$/
+            'step-after'
+          else
+            'linear'
+        end
+        return nil if hierarchy_build_implied(s)
+        root = s.nodes[0]
+        group = s.group
+        breadth =nil
+        depth = nil 
+        leaf_count = 0
+        leaf_index = 0.5 - group / 2.0
+
+        # Count the leaf nodes and compute the depth of descendants. #/
+        par = nil
+        root.visit_after {|n,i|
+          #puts "#{n.node_value} #{i}"
+          if (n.first_child) 
+            n.depth = 1 + Rubyvis.max(n.child_nodes, lambda {|nn| nn.depth })
+          else
+            if (group!=0 and (par != n.parent_node)) 
+              par = n.parent_node
+              leaf_count += group
+            end
+            leaf_count+=1
+            n.depth = 0
+          end
+        }
+        breadth = 1.0 / leaf_count
+        depth = 1.0 / root.depth
+
+        # Compute the unit breadth and depth of each node. #/
+        par = nil
+        root.visit_after  {|n,i|
+          if (n.first_child) 
+              n.breadth = Rubyvis.mean(n.child_nodes, lambda {|nn| nn.breadth })
+           else 
+            if (group!=0 and (par != n.parent_node)) 
+            par = n.parent_node
+            leaf_index += group
+            end
+            n.breadth = breadth * leaf_index
+            leaf_index+=1
+          end
+          n.depth = 1 - n.depth * depth
+        }
+
+        # Compute breadth and depth ranges for space-filling layouts. #/
+        root.visit_after {|n,i|
+          n.min_breadth = n.first_child ? n.first_child.min_breadth : (n.breadth - breadth / 2.0)
+          n.max_breadth = n.first_child ? n.last_child.max_breadth : (n.breadth + breadth / 2.0)
+        }
+        root.visit_before {|n,i|
+          n.min_depth = n.parent_node ? n.parent_node.max_depth : 0
+          n.max_depth = n.parent_node ? (n.depth + root.depth) : (n.min_depth + 2 * root.depth)
+        }
+        root.min_depth = -depth
+        node_link_build_implied(s)
+        false
+      end
+      # Constructs a new, empty space-filling cluster layout. Layouts are not
+      # typically constructed directly; instead, they are added to an existing panel
+      # via {@link pv.Mark#add}.
+      #
+      # @class A variant of cluster layout that is space-filling. The meaning of the
+      # exported mark prototypes changes slightly in the space-filling
+      # implementation:<ul>
+      #
+      # <li><tt>node</tt> - for rendering nodes; typically a {@link pv.Bar} for
+      # non-radial orientations, and a {@link pv.Wedge} for radial orientations.
+      #
+      # <p><li><tt>link</tt> - unsupported; undefined. Links are encoded implicitly
+      # in the arrangement of the space-filling nodes.
+      #
+      # <p><li><tt>label</tt> - for rendering node labels; typically a
+      # Rubyvis::Label.
+      #
+      # </ul>For more details on how to use this layout, see
+      # {@link pv.Layout.Cluster}.
+      #
+      # @extends pv.Layout.Cluster
+      class Fill < Cluster
+        include Hierarchy::Fill
+        @properties=Cluster.properties.dup  
+        def initialize
+          super
+          fill_constructor
+        end
+        def build_implied(s)
+          return nil if cluster_build_implied(s)
+          fill_build_implied(s)
+        end
+      end
+      
+    end
+  end
+end
diff --git a/lib/rubyvis/layout/grid.rb b/lib/rubyvis/layout/grid.rb
new file mode 100644
index 0000000..4ffeccf
--- /dev/null
+++ b/lib/rubyvis/layout/grid.rb
@@ -0,0 +1,105 @@
+module Rubyvis
+  class Layout
+    # Alias for Rubyvis::Layout::Grid 
+    def self.Grid
+      Rubyvis::Layout::Grid
+    end
+    
+    # Implements a grid layout with regularly-sized rows and columns. The
+    # number of rows and columns are determined from their respective
+    # properties. For example, the 2×3 array:
+    #
+    # <pre>1 2 3
+    # 4 5 6</pre>
+    #
+    # can be represented using the <tt>rows</tt> property as:
+    #
+    # <pre>[[1, 2, 3], [4, 5, 6]]</pre>
+    #
+    # If your data is in column-major order, you can equivalently use the
+    # <tt>columns</tt> property. If the <tt>rows</tt> property is an array, it
+    # takes priority over the <tt>columns</tt> property. The data is implicitly
+    # transposed, as if the {@link pv.transpose} operator were applied.
+    #
+    # <p>This layout exports a single <tt>cell</tt> mark prototype, which is
+    # intended to be used with a bar, panel, layout, or subclass thereof. The data
+    # property of the cell prototype is defined as the elements in the array. For
+    # example, if the array is a two-dimensional array of values in the range
+    # [0,1], a simple heatmap can be generated as:
+    #
+    # <pre>vis.add(pv.Layout.Grid)
+    #     .rows(arrays)
+    #   .cell.add(pv.Bar)
+    #     .fillStyle(pv.ramp("white", "black"))</pre>
+    #
+    # The grid subdivides the full width and height of the parent panel into equal
+    # rectangles. Note, however, that for large, interactive, or animated heatmaps,
+    # you may see significantly better performance through dynamic {@link pv.Image}
+    # generation.
+    #
+    # <p>For irregular grids using value-based spatial partitioning, see {@link
+    # pv.Layout.Treemap}.
+
+    
+    
+    class Grid < Layout
+      attr_accessor :_grid
+      attr_accessor :cell
+      @properties=Layout.properties.dup
+      def initialize
+        super
+        @cell=_cell
+      end
+      def _cell
+        that=self
+        m=Rubyvis::Mark.new().
+          data(lambda {that.scene[that.index]._grid}).
+          width(lambda {that.width/that.cols.to_f}).
+          height(lambda {that.height/that.rows.to_f}).
+          left(lambda {(that.width/that.cols.to_f)*(self.index % that.cols)}).
+          top(lambda {(that.height/that.rows.to_f)*(self.index / that.cols).floor})
+        m.parent=self
+        m
+      end
+      private :_cell
+      
+      
+      ##
+      # :attr: rows
+      # The number of rows. This property can also be specified as the data in
+      # row-major order; in this case, the rows property is implicitly set to the
+      # length of the array, and the cols property is set to the length of the first
+      # element in the array.
+      #
+      
+      ##
+      # :attr: cols
+      #
+      # The number of columns. This property can also be specified as the data in
+      # column-major order; in this case, the cols property is implicitly set to the
+      # length of the array, and the rows property is set to the length of the first
+      # element in the array.
+      #
+
+      attr_accessor_dsl :rows, :cols
+      def self.defaults
+        Rubyvis::Layout::Grid.new.mark_extend(Rubyvis::Layout.defaults).
+          rows(1).
+          cols(1)
+      end
+      def build_implied(s)
+        layout_build_implied(s)
+        r=s.rows
+        c=s.cols
+        r=Rubyvis.transpose(c) if c.is_a? Array
+        if r.is_a? Array
+          s._grid=Rubyvis.blend(r)
+          s.rows=r.size
+          s.cols=r[0] ? r[0].size : 0
+        else
+          s._grid=Rubyvis.repeat([s.data],r*c)
+        end
+      end
+    end
+  end
+end
diff --git a/lib/rubyvis/layout/hierarchy.rb b/lib/rubyvis/layout/hierarchy.rb
new file mode 100644
index 0000000..9bc30b3
--- /dev/null
+++ b/lib/rubyvis/layout/hierarchy.rb
@@ -0,0 +1,249 @@
+module Rubyvis
+  class Layout
+    # Alias for Rubyvis::Layout::Hierarchy
+    def self.Hierarchy
+      Rubyvis::Layout::Hierarchy
+    end
+    # Represents an abstract layout for hierarchy diagrams. This class is a
+    # specialization of Rubyvis::Layout::Network, providing the basic structure
+    # for both hierarchical node-link diagrams (such as Reingold-Tilford trees) and
+    # space-filling hierarchy diagrams (such as sunbursts and treemaps).
+    #
+    # <p>Unlike general network layouts, the +links+ property need not be
+    # defined explicitly. Instead, the links are computed implicitly from the
+    # +parent_node+ attribute of the node objects, as defined by the
+    # +nodes+ property. This implementation is also available as
+    # +Hierarchy.links, for reuse with non-hierarchical layouts; for example, to
+    # render a tree using force-directed layout.
+    #
+    # <p>Correspondingly, the +nodes+ property is represented as a union of
+    # Rubyvis::Layout::Network::Node} and Rubyvis::Dom::Node. To construct a node
+    # hierarchy from a simple JSON map, use the Rubyvis::Dom operator; this
+    # operator also provides an easy way to sort nodes before passing them to the
+    # layout.
+    #
+    # <p>For more details on how to use this layout, see
+    # Rubyvis::Layout::Network
+    #
+    # @see Rubyvis::Layout::Cluster
+    # @see Rubyvis::Layout::Partition
+    # @see Rubyvis::Layout::Tree
+    # @see Rubyvis::Layout::Treemap
+    # @see Rubyvis::Layout::Indent
+    # @see Rubyvis::Layout::Pack
+    class Hierarchy < Network
+      @properties=Network.properties.dup
+      def initialize
+        super
+        @link.stroke_style("#ccc")
+      end
+      def build_implied(s)
+        hierarchy_build_implied(s)
+      end
+      # @private Compute the implied links. (Links are null by default.) */
+      def hierarchy_build_implied(s)
+        s.links=self.links() if !s.links
+        network_build_implied(s)
+      end
+
+      # The implied links; computes links using the <tt>parent_node</tt> attribute.
+      def links
+        l=self.nodes().find_all {|n| n.parent_node}
+        l.map {|n|
+          
+          Network::Link.new({
+              :source_node=>n,
+              :target_node=>n.parent_node,
+              :link_value=>1
+        })}
+      end
+    end
+    
+    module NodeLink
+      attr_accessor :_ir, :_or, :_orient, :_w, :_h
+      def node_link_build_implied(s)
+        nodes = s.nodes
+        @_orient= s.orient
+        horizontal= case @_orient
+          when /^(top|bottom)$/
+            true
+          else
+            false
+          end
+        @_w = s.width
+        @_h = s.height
+        
+        # /* Compute default inner and outer radius. */
+        if (@_orient == "radial") 
+          @_ir = s.inner_radius
+          @_or = s.outer_radius
+          @_ir||=0
+          @_or||=[@_w, at _h].min / 2.0
+        end
+        nodes.each_with_index{|n,i|
+          n.mid_angle = (@_orient == "radial") ? mid_angle(n) : (horizontal ? Math::PI / 2.0 : 0)
+          n.x = node_link_x(n)
+          n.y = node_link_y(n)
+          n.mid_angle+=Math::PI if (n.first_child)
+        }
+        false
+      end
+      def radius(n)
+        n.parent_node ? (n.depth * (@_or- at _ir)+ at _ir) : 0
+      end
+      def mid_angle(n)
+        n.parent_node ? ((n.breadth - 0.25) * 2 * Math::PI ) : 0
+      end
+      def node_link_x(n)
+        case @_orient
+          when "left"
+            n.depth*@_w
+          when "right"
+            @_w-n.depth*@_w
+          when "top"
+            n.breadth*@_w
+          when "bottom"
+            @_w-n.breath*@_w
+          when "radial"
+            @_w/2.0+radius(n)*Math.cos(n.mid_angle)
+        end
+      end
+      def node_link_y(n)
+        case @_orient
+          when "left"
+            n.breadth*@_h
+          when "right"
+            @_h-n.depth*@_h
+          when "top"
+            n.depth*@_h            
+          when "bottom"
+            @_h-n.breath*@_h
+          when "radial"
+            @_h / 2.0 + radius(n) * Math.sin(n.mid_angle)
+        end # end case
+      end # end method
+      private :node_link_y, :node_link_x, :mid_angle, :radius
+    end # end class
+    
+    module Fill
+      attr_accessor :ir, :_or, :_orient, :_w, :_h
+      def fill_constructor
+        @node.stroke_style("#fff").
+          fill_style("#ccc").
+          width(lambda {|n| n.dx}).
+          height(lambda {|n| n.dy}).
+          inner_radius(lambda {|n| n.inner_radius}).
+          outer_radius(lambda {|n| n.outer_radius}).
+          start_angle(lambda {|n| n.start_angle}).
+          angle(lambda {|n| n.angle})
+        
+          @node_label.
+            text_align("center").
+            left(lambda {|n| n.x+ (n.dx / 2.0) }).
+            top(lambda {|n| n.y+(n.dy / 2.0)})
+          @link=nil
+        
+      end
+      
+      def fill_build_implied(s)
+        nodes = s.nodes
+        @_orient= s.orient
+        @_orient=~/^(top|bottom)$/
+        horizontal = !$1.nil?
+        @_w = s.width
+        @_h = s.height
+        @_depth = -nodes[0].min_depth
+        if @_orient == "radial"
+          @_ir = s.inner_radius
+          @_or = s.outer_radius
+          @_ir||=0
+          @_depth = @_depth * 2 if @_ir!=0
+          @_or||=[@_w, at _h].min / 2.0
+        end
+        nodes.each_with_index {|n,i|
+          n.x = fill_x(n)
+          n.y = fill_y(n)
+          if @_orient == "radial"
+            n.inner_radius = inner_radius(n);
+            n.outer_radius = outer_radius(n);
+            n.start_angle = start_angle(n);
+            n.angle = angle(n);
+            n.mid_angle = n.start_angle + n.angle / 2.0
+          else 
+            n.mid_angle = horizontal ? -Math::PI / 2.0 : 0
+          end
+          n.dx = dx(n)
+          n.dy = dy(n)
+        }
+        false
+      end
+      
+      def fill_scale(d, depth)
+        (d + depth) / (1 + depth).to_f
+      end
+      def fill_x(n)
+        case @_orient
+          when "left"
+            fill_scale(n.min_depth, at _depth)*@_w
+          when "right"
+            (1-fill_scale(n.max_depth, at _depth))*@_w
+          when "top"
+            n.min_breadth*@_w
+          when "bottom"
+            (1-n.max_breath)*@_w
+          when "radial"
+            @_w / 2.0
+        end
+      end
+      def fill_y(n)
+        case @_orient
+          when "left"
+            n.min_breadth*@_h
+          when "right"
+            (1-n.max_breadth)*@_h
+          when "top"
+            fill_scale(n.min_depth, @_depth) * @_h            
+          when "bottom"
+            (1-fill_scale(n.max_depth, @_depth)) * @_h
+          when "radial"
+            @_h / 2.0
+        end # end case
+      end # end method
+      
+      def dx(n)
+        if @_orient=='left' or @_orient=='right'
+          (n.max_depth - n.min_depth) / (1.0 + @_depth) * @_w
+        elsif @_orient=='top' or @_orient=='bottom'
+          (n.max_breadth - n.min_breadth) * @_w
+        elsif @_orient=='radial'
+          n.parent_node ? (n.inner_radius + n.outer_radius) * Math.cos(n.mid_angle) : 0
+        end          
+      end
+      
+      def dy(n)
+        if @_orient=='left' or @_orient=='right'
+          (n.max_breadth - n.min_breadth) * @_h
+        elsif @_orient=='top' or @_orient=='bottom'
+          (n.max_depth - n.min_depth) / (1.0 + @_depth) * @_h
+        elsif orient=='radial'
+          n.parent_node ? (n.inner_radius + n.outer_radius) * Math.sin(n.mid_angle) : 0
+        end        
+      end
+      
+      def inner_radius(n)
+        [0, fill_scale(n.min_depth, @_depth/2.0)].max * (@_or - @_ir) + @_ir
+      end
+      
+      def outer_radius(n)
+        fill_scale(n.max_depth, @_depth / 2.0) * (@_or - @_ir) + @_ir
+      end
+      
+      def start_angle(n)
+        (n.parent_node ? n.min_breadth - 0.25 : 0) * 2 * Math::PI
+      end
+      def angle(n)
+        (n.parent_node ? n.max_breadth - n.min_breadth : 1 ) * 2 * Math::PI
+      end
+    end
+  end
+end
diff --git a/lib/rubyvis/layout/horizon.rb b/lib/rubyvis/layout/horizon.rb
new file mode 100644
index 0000000..0935551
--- /dev/null
+++ b/lib/rubyvis/layout/horizon.rb
@@ -0,0 +1,153 @@
+module Rubyvis
+  class Layout
+    # Alias for Rubyvis::Layout::Horizon
+    def self.Horizon
+      Rubyvis::Layout::Horizon
+    end
+    
+    # Implements a horizon layout, which is a variation of a single-series
+    # area chart where the area is folded into multiple bands. Color is used to
+    # encode band, allowing the size of the chart to be reduced significantly
+    # without impeding readability. This layout algorithm is based on the work of
+    # J. Heer, N. Kong and M. Agrawala in {Sizing
+    # the Horizon: The Effects of Chart Size and Layering on the Graphical
+    # Perception of Time Series Visualizations}[http://hci.stanford.edu/publications/2009/heer-horizon-chi09.pdf], CHI 2009.
+    #
+    # <p>This layout exports a single <tt>band</tt> mark prototype, which is
+    # intended to be used with an area mark. The band mark is contained in a panel
+    # which is replicated per band (and for negative/positive bands). For example,
+    # to create a simple horizon graph given an array of numbers:
+    #
+    #   vis.add(Rubyvis::Layout::Horizon)
+    #     .bands(n)
+    #   .band.add(Rubyvis::Area)
+    #     .data(data)
+    #     .left(lambda { index * 35})
+    #     .height(lambda {|d| d * 40})
+    #
+    # The layout can be further customized by changing the number of bands, and
+    # toggling whether the negative bands are mirrored or offset. (See the
+    # above-referenced paper for guidance.)
+    #
+    # <p>The <tt>fill_style</tt> of the area can be overridden, though typically it
+    # is easier to customize the layout's behavior through the custom
+    # <tt>background_style</tt>, <tt>positive_style</tt> and <tt>negative_style</tt>
+    # properties. By default, the background is white, positive bands are blue, and
+    # negative bands are red. For the most accurate presentation, use fully-opaque
+    # colors of equal intensity for the negative and positive bands.
+    class Horizon < Layout
+      @properties=Layout.properties.dup      
+      # The band prototype. This prototype is intended to be used with an Area
+      # mark to render the horizon bands.
+      attr_accessor :band
+      attr_accessor :_bands, :_mode, :_size, :_fill, :_red, :_blue
+      def initialize
+        super
+        @_bands=nil
+        @_mode=nil # cached mode
+        @_size=nil # cached height
+        @_fill=nil # cached background style
+        @_red=nil # cached negative color (ramp)
+        @_blue=nil # cached positive color (ramp)
+        @_bands_panel=_bands_panel
+        @band=_band
+      end
+      def build_implied(s)
+        layout_build_implied(s) 
+        @_bands=s.bands
+        @_mode=s.mode
+        @_size=((@_mode == "color" ? 0.5 : 1) * s.height).round
+        @_fill=s.background_style
+        @_red=Rubyvis.ramp(@_fill, s.negative_style).domain(0, at _bands)
+        @_blue=Rubyvis.ramp(@_fill, s.positive_style).domain(0, at _bands)
+        
+      end
+      def _bands_panel
+        that=self
+        Rubyvis::Panel.new().
+          data(lambda {Rubyvis.range(that._bands.to_f * 2)}).
+          overflow("hidden").
+          height(lambda {that._size}).
+          top(lambda {|i| that._mode=='color' ? (i & 1) * that._size : 0 }).
+          fill_style(lambda {|i| i!=0 ? nil : that._fill})
+      end
+      
+      def _band
+        that=self
+        m=Rubyvis::Mark.new().
+        top(lambda  {|d,i|
+          (that._mode == "mirror" and (i & 1)!=0) ? (i + 1 >> 1) * that._size : nil
+        }).
+        bottom(lambda {|d,i|
+            crit= (i & 1)!= 0 ? i & 1 : -1
+          (that._mode == "mirror") ? ((i & 1)!=0 ? nil : (i + 1 >> 1) * -that._size) : (crit * (i + 1 >> 1) * that._size)
+        }).
+        fill_style(lambda {|d,i|
+            ((i & 1)!=0 ? that._red : that._blue).scale((i >> 1) + 1)
+        })
+        
+        class << m # :nodoc:
+          def that_and_bands(that,bands)
+            @that = that
+            @bands=bands
+          end
+          def add(type)
+            bands=@bands
+            that = @that
+            that.add( Rubyvis.Panel ).mark_extend(bands). add(type). mark_extend(self)
+          end
+        end
+        
+        m.that_and_bands(self, @_bands_panel)
+        m
+      end
+      
+      ##
+      # :attr: mode
+      # The horizon mode: offset, mirror, or color. The default is "offset".
+      
+      ##
+      # :attr: bands
+      # The number of bands. Must be at least one. The default value is two.
+      #
+      
+      ##
+      # :attr: positive_style
+      # The positive band color; if non-null, the interior of positive bands are
+      # filled with the specified color. The default value of this property is blue.
+      # For accurate blending, this color should be fully opaque.
+      #
+      
+      ##
+      # :attr: negative_style
+      # The negative band color; if non-null, the interior of negative bands are
+      # filled with the specified color. The default value of this property is red.
+      # For accurate blending, this color should be fully opaque.
+      #
+      
+      ##
+      # :attr: background_style
+      # The background color. The panel background is filled with the specified
+      # color, and the negative and positive bands are filled with an interpolated
+      # color between this color and the respective band color. The default value of
+      # this property is white. For accurate blending, this color should be fully
+      # opaque.
+      #
+      
+      attr_accessor_dsl :bands, :mode, :background_style, [:background_style, lambda {|d| Rubyvis.color(d)}], [:positive_style, lambda {|d| Rubyvis.color(d)}], [:negative_style, lambda {|d| Rubyvis.color(d)}]
+
+      # Default properties for horizon layouts. By default, there are two bands, the
+      # mode is "offset", the background style is "white", the positive style is
+      # blue, negative style is red.
+      def self.defaults
+        Horizon.new.mark_extend(Layout.defaults).
+          bands(2).
+          mode('offset').
+          background_style('white').
+          positive_style('#1f77b4').
+          negative_style('#d62728')
+      end
+    end
+  end
+end
+
diff --git a/lib/rubyvis/layout/indent.rb b/lib/rubyvis/layout/indent.rb
new file mode 100644
index 0000000..37ca5e8
--- /dev/null
+++ b/lib/rubyvis/layout/indent.rb
@@ -0,0 +1,81 @@
+module Rubyvis
+  class Layout
+    # Alias for Rubyvis::Layout::Indent 
+    def self.Indent
+      Rubyvis::Layout::Indent
+    end
+    # Implements a hierarchical layout using the indent algorithm. This
+    # layout implements a node-link diagram where the nodes are presented in
+    # preorder traversal, and nodes are indented based on their depth from the
+    # root. This technique is used ubiquitously by operating systems to represent
+    # file directories; although it requires much vertical space, indented trees
+    # allow efficient <i>interactive</i> exploration of trees to find a specific
+    # node. In addition they allow rapid scanning of node labels, and multivariate
+    # data such as file sizes can be displayed adjacent to the hierarchy.
+    #
+    # <p>The indent layout can be configured using the <tt>depth</tt> and
+    # <tt>breadth</tt> properties, which control the increments in pixel space for
+    # each indent and row in the layout. This layout does not support multiple
+    # orientations; the root node is rendered in the top-left, while
+    # <tt>breadth</tt> is a vertical offset from the top, and <tt>depth</tt> is a
+    # horizontal offset from the left.
+    #
+    # <p>For more details on how to use this layout, see
+    # Rubyvis::Layout::Hierarchy
+    class Indent < Hierarchy
+      @properties=Hierarchy.properties.dup 
+      # Constructs a new, empty indent layout. Layouts are not typically constructed
+      # directly; instead, they are added to an existing panel via
+      # Rubyvis::Mark.add
+      def initialize
+        super
+        @link.interpolate("step-after")
+      end
+      
+      ##
+      # :attr: depth
+      # The horizontal offset between different levels of the tree; defaults to 15.
+      #
+      
+      ##
+      # :attr: breadth
+      # The vertical offset between nodes; defaults to 15.
+      #
+      
+      attr_accessor_dsl :depth, :breadth
+      
+      # Default properties for indent layouts. By default the depth and breadth
+      # offsets are 15 pixels.
+      def self.defaults
+        Rubyvis::Layout::Indent.new.mark_extend(Rubyvis::Layout::Hierarchy.defaults).
+          depth(15).
+          breadth(15)
+      end
+      
+      def position(n, breadth, depth)
+        n.x = @ax + depth * @dspace
+        depth+=1
+        n.y = @ay + breadth * @bspace
+        breadth+=1
+        n.mid_angle = 0
+        c=n.first_child
+        while c
+          breadth=position(c,breadth,depth)
+          c=c.next_sibling
+        end
+        breadth;
+      end
+      private :position
+      def build_implied(s)
+        return nil if hierarchy_build_implied(s)
+        nodes = s.nodes
+        @bspace = s.breadth
+        @dspace = s.depth
+        @ax = 0
+        @ay = 0
+        position(nodes[0], 1, 1)
+      end
+      
+    end
+  end
+end
diff --git a/lib/rubyvis/layout/matrix.rb b/lib/rubyvis/layout/matrix.rb
new file mode 100644
index 0000000..500e0da
--- /dev/null
+++ b/lib/rubyvis/layout/matrix.rb
@@ -0,0 +1,188 @@
+module Rubyvis
+  class Layout
+    # Alias for Rubyvis::Layout::Matrix
+    def self.Matrix
+      Rubyvis::Layout::Matrix
+    end
+
+    # Implements a network visualization using a matrix view. This is, in
+    # effect, a visualization of the graph's <i>adjacency matrix</i>: the cell at
+    # row <i>i</i>, column <i>j</i>, corresponds to the link from node <i>i</i> to
+    # node <i>j</i>. The fill color of each cell is binary by default, and
+    # corresponds to whether a link exists between the two nodes. If the underlying
+    # graph has links with variable values, the <tt>fillStyle</tt> property can be
+    # substited to use an appropriate color function, such as {@link pv.ramp}.
+    #
+    # <p>For undirected networks, the matrix is symmetric around the diagonal. For
+    # directed networks, links in opposite directions can be rendered on opposite
+    # sides of the diagonal using <tt>directed(true)</tt>. The graph is assumed to
+    # be undirected by default.
+    #
+    # <p>The mark prototypes for this network layout are slightly different than
+    # other implementations:<ul>
+    #
+    # <li><tt>node</tt> - unsupported; undefined. No mark is needed to visualize
+    # nodes directly, as the nodes are implicit in the location (rows and columns)
+    # of the links.
+    #
+    # <p><li><tt>link</tt> - for rendering links; typically a {@link pv.Bar}. The
+    # link mark is added directly to the layout, with the data property defined as
+    # all possible pairs of nodes. Each pair is represented as a
+    # {@link pv.Network.Layout.Link}, though the <tt>linkValue</tt> attribute may
+    # be 0 if no link exists in the graph.
+    #
+    # <p><li><tt>label</tt> - for rendering node labels; typically a
+    # {@link pv.Label}. The label mark is added directly to the layout, with the
+    # data property defined via the layout's <tt>nodes</tt> property; note,
+    # however, that the nodes are duplicated so as to provide a label across the
+    # top and down the side. Properties such as <tt>strokeStyle</tt> and
+    # <tt>fillStyle</tt> can be overridden to compute properties from node data
+    # dynamically.
+    #
+    # </ul>For more details on how to use this layout, see
+    # {@link pv.Layout.Network}.
+    class Matrix < Network
+      @properties=Network.properties.dup
+      attr_accessor :_n, :_dx, :_dy, :_labels, :_pairs
+      def build_implied_post(s)
+        @_n = s.nodes.size
+        @_dx = s.width.to_f / @_n
+        @_dy = s.height.to_f / @_n
+        @_labels = s._matrix.labels
+        @_pairs = s._matrix.pairs
+      end
+      # Deletes special add from network
+      def _link # :nodoc:
+        #that=self
+        l=Mark.new().
+        mark_extend(@node).
+        data(lambda {|d| [d.source_node, d.target_node] }).
+        fill_style(nil).
+        line_width(lambda {|d,_p| _p.link_value * 1.5 }).
+        stroke_style("rgba(0,0,0,.2)")
+        l
+      end
+
+      def initialize
+        super
+        @_n=nil, # cached matrix size
+        @_dx=nil, # cached cell width
+        @_dy=nil, # cached cell height
+        @_labels=nil, # cached labels (array of strings)
+        @_pairs=nil, # cached pairs (array of links)
+        that=self
+        #/* Links are all pairs of nodes. */
+        @link.data(lambda  {that._pairs}).
+          left(lambda { that._dx * (self.index % that._n) }).
+          top(lambda  { that._dy * (self.index / that._n.to_f).floor }).
+          width(lambda  { that._dx }).
+          height(lambda  { that._dy }).
+          line_width(1.5).
+          stroke_style("#fff").
+        fill_style(lambda {|l| l.link_value!=0 ? "#555" : "#eee" })
+
+        @link.parent = self
+        #/* No special add for links! */
+
+        # delete this.link.add;
+
+        #/* Labels are duplicated for top & left. */
+        @node_label.
+        data(lambda  { that._labels }).
+        left(lambda  { (self.index & 1)!=0 ? that._dx * ((self.index >> 1) + 0.5) : 0 }).
+        top(lambda  { (self.index & 1)!=0 ? 0 : that._dy * ((self.index >> 1) + 0.5) }).
+        text_margin(4).text_align(lambda  { (self.index & 1)!=0 ? "left" : "right"; }).
+        text_angle(lambda  { (self.index & 1)!=0 ? -Math::PI / 2.0 : 0; });
+        @node=nil
+      end
+      def self.defaults
+        Matrix.new.mark_extend(Network.defaults).
+        directed(true)
+      end
+      ##
+      # :attr: directed
+      #
+      # Whether this matrix visualization is directed (bidirectional). By default,
+      # the graph is assumed to be undirected, such that the visualization is
+      # symmetric across the matrix diagonal. If the network is directed, then
+      # forward links are drawn above the diagonal, while reverse links are drawn
+      # below.
+      #
+      # @type boolean
+      # @name pv.Layout.Matrix.prototype.directed
+      #/
+
+      attr_accessor_dsl :directed
+
+
+      # Specifies an optional sort function. The sort function follows the same
+      # comparator contract required by {@link pv.Dom.Node#sort}. Specifying a sort
+      # function provides an alternative to sort the nodes as they are specified by
+      # the <tt>nodes</tt> property; the main advantage of doing this is that the
+      # comparator function can access implicit fields populated by the network
+      # layout, such as the <tt>linkDegree</tt>.
+      #
+      # <p>Note that matrix visualizations are particularly sensitive to order. This
+      # is referred to as the seriation problem, and many different techniques exist
+      # to find good node orders that emphasize clusters, such as spectral layout and
+      # simulated annealing.
+      #
+      # @param {function} f comparator function for nodes.
+      # @returns {pv.Layout.Matrix} this.
+      #/
+      def sort(f=nil,&block)
+        f||=block
+        @sort=f
+        self
+      end
+      def build_implied(s) # :nodoc:
+        return nil if network_build_implied(s)
+        nodes = s.nodes
+        links = s.links
+        sort = @sort
+
+        n = nodes.size
+        index = Rubyvis.range(n)
+        labels = []
+        pairs = []
+        map = {}
+
+        s._matrix = OpenStruct.new({:labels=> labels, :pairs=> pairs})
+
+        #/* Sort the nodes. */
+        if sort
+          index.sort! {|a,b| sort.call(nodes[a],nodes[b])}
+        end
+        #/* Create pairs. */
+        n.times {|i|
+          n.times {|j|
+            a = index[i]
+            b = index[j]
+            _p = OpenStruct.new({
+              :row=> i,
+              :col=> j,
+              :source_node=> nodes[a],
+              :target_node=> nodes[b],
+            :link_value=> 0})
+            map["#{a}.#{b}"] = _p
+            pairs.push(map["#{a}.#{b}"])
+          }
+        }
+        #/* Create labels. */
+        n.times {|i|
+          a = index[i]
+          labels.push(nodes[a], nodes[a])
+        }
+        #/* Accumulate link values. */
+        links.each_with_index {|l,i|
+          source = l.source_node.index
+          target = l.target_node.index
+          value = l.link_value
+          map["#{source}.#{target}"].link_value += value
+          map["#{target}.#{source}"].link_value += value if (!s.directed)
+        }
+        build_implied_post(s)
+      end
+    end
+  end
+end
diff --git a/lib/rubyvis/layout/network.rb b/lib/rubyvis/layout/network.rb
new file mode 100644
index 0000000..a79ecbe
--- /dev/null
+++ b/lib/rubyvis/layout/network.rb
@@ -0,0 +1,337 @@
+module Rubyvis
+  class Layout
+    # Alias for Rubyvis::Layout::Network 
+    def self.Network
+      Rubyvis::Layout::Network
+    end
+
+    # Represents an abstract layout for network diagrams. This class
+    # provides the basic structure for both node-link diagrams (such as
+    # force-directed graph layout) and space-filling network diagrams (such as
+    # sunbursts and treemaps). Note that "network" here is a general term that
+    # includes hierarchical structures; a tree is represented using links from
+    # child to parent.
+    #
+    # Network layouts require the graph data structure to be defined using two
+    # properties:<ul>
+    #
+    # <li><tt>nodes</tt> - an array of objects representing nodes. Objects in this array must conform to the Rubyvis::Layout::Network::Node interface; which is
+    # to say, be careful to avoid naming collisions with automatic attributes such
+    # as <tt>index</tt> and <tt>link_degree</tt>.
+    # If the nodes property is defined
+    # as an array of primitives, such as numbers or strings, these primitives are
+    # automatically wrapped in an object; the resulting object's <tt>node_value</tt>
+    # attribute points to the original primitive value.
+    #
+    # <p><li><tt>links</tt> - an array of objects representing links. Objects in
+    # this array must conform to the Rubyvis::Layout::Network::Link interface; at a minimum, either <tt>source</tt> and <tt>target</tt> indexes or
+    # <tt>source_node</tt> and <tt>target_node</tt> references must be set. Note that
+    # if the links property is defined after the nodes property, the links can be defined in terms of <tt>this.nodes()</tt>.
+    #
+    # </ul>
+    #
+    # <p>Three standard mark prototypes are provided:<ul>
+    #
+    # <li><tt>node</tt> - for rendering nodes; typically a Rubyvis::Dot. The node mark is added directly to the layout, with the data property defined via the layout's <tt>nodes</tt> property. Properties such as <tt>stroke_style</tt> and <tt>fillStyle</tt> can be overridden to compute properties from node data dynamically.
+    #
+    # <p><li><tt>link</tt> - for rendering links; typically a Rubyvis::Line. The
+    # link mark is added to a child panel, whose data property is defined as
+    # layout's <tt>links</tt> property. The link's data property is then a
+    # two-element array of the source node and target node. Thus, poperties such as
+    # <tt>stroke_style</tt> and <tt>fill_style</tt> can be overridden to compute
+    # properties from either the node data (the first argument) or the link data
+    # (the second argument; the parent panel data) dynamically.
+    #
+    # <p><li><tt>node_label</tt> - for rendering node labels; typically a
+    # Rubyvis::Label. The label mark is added directly to the layout, with the
+    # data property defined via the layout's <tt>nodes</tt> property. Properties
+    # such as <tt>strokeStyle</tt> and <tt>fillStyle</tt> can be overridden to
+    # compute properties from node data dynamically.
+    #
+    # </ul>Note that some network implementations may not support all three
+    # standard mark prototypes; for example, space-filling hierarchical layouts
+    # typically do not use a <tt>link</tt> prototype, as the parent-child links are
+    # implied by the structure of the space-filling <tt>node</tt> marks.  Check the
+    # specific network layout for implementation details.
+    #
+    # <p>Network layout properties, including <tt>nodes</tt> and <tt>links</tt>,
+    # are typically cached rather than re-evaluated with every call to render. This
+    # is a performance optimization, as network layout algorithms can be
+    # expensive. If the network structure changes, call {@link #reset} to clear the
+    # cache before rendering. Note that although the network layout properties are
+    # cached, child mark properties, such as the marks used to render the nodes and
+    # links, <i>are not</i>. Therefore, non-structural changes to the network
+    # layout, such as changing the color of a mark on mouseover, do not need to
+    # reset the layout.
+    #
+    # @see Rubyvis::Layout::Hierarchy
+    # @see Rubyvis::Layout::Force
+    # @see Rubyvis::Layout::Matrix
+    # @see Rubyvis::Layout::Arc
+    # @see Rubyvis::Layout::Rollup
+    class Network < Rubyvis::Layout
+      @properties=Layout.properties.dup
+      # The node prototype. This prototype is intended to be used with a 
+      # Dot mark in conjunction with the link prototype.
+      attr_accessor :node
+      # The link prototype, which renders edges between source nodes and target
+      # nodes. This prototype is intended to be used with a Line mark in
+      # conjunction with the node prototype.      
+      attr_accessor :link
+      # The node label prototype, which renders the node name adjacent to the node.
+      # This prototype is provided as an alternative to using the anchor on the
+      # node mark; it is primarily intended to be used with radial node-link
+      # layouts, since it provides a convenient mechanism to set the text angle.
+      #
+      # NOTE FOR PROTOVIS USERS: The original name of method was +label+
+      # but it was replaced to not conflict with rubyvis shortcut
+      # method Mark.label()       
+      attr_accessor :node_label
+      attr_accessor :_id
+      def initialize
+        super
+        @_id=Rubyvis.id()
+        @node=_node
+        @link=_link
+        @node_label=_node_label
+      end
+           
+      def _node #:nodoc:
+        that=self        
+        m=Mark.new().
+          data(lambda {that.nodes}).
+          stroke_style("#1f77b4").
+          fill_style("#fff").
+          left(lambda {|n| n.x }).
+          top(lambda {|n| n.y })
+        m.parent = self
+        m 
+      end
+      module LinkAdd # :nodoc:
+        attr_accessor :that
+        def add(type)
+          that=@that
+          return that.add(Rubyvis::Panel).
+          data(lambda {that.links}).
+          add(type).
+          mark_extend(self)
+        end
+      end
+      
+    
+      
+      def _link # :nodoc:
+        #that=self
+        l=Mark.new().
+          mark_extend(@node).
+          data(lambda {|d| [d.source_node, d.target_node] }).
+          fill_style(nil).
+          line_width(lambda {|d,_p| _p.link_value * 1.5 }).
+          stroke_style("rgba(0,0,0,.2)")
+        l.extend LinkAdd
+        l.that=self
+        l
+      end
+
+     
+      def _node_label #:nodoc:
+        #that=self
+        nl=Mark.new().
+          mark_extend(@node).
+          text_margin(7).
+          text_baseline("middle").
+          text(lambda {|n| n.node_name ? n.node_name : n.node_value }).
+          text_angle(lambda {|n| 
+            a = n.mid_angle
+            Rubyvis::Wedge.upright(a) ? a : (a + Math::PI)
+          }).
+          text_align(lambda {|n| 
+            Rubyvis::Wedge.upright(n.mid_angle) ? "left" : "right"
+          })
+        nl.parent = self
+        nl
+      end
+      
+      ##
+      # :attr: nodes
+      #
+      # an array of objects representing nodes. Objects in this  array must conform to the Rubyvis::Layout::Network::Node interface; which is
+      # to say, be careful to avoid naming collisions with automatic attributes such
+      # as <tt>index</tt> and <tt>link_degree</tt>. If the nodes property is defined
+      # as an array of 'primitives' (objects which doesn't respond to node_value)
+      # these primitives are automatically wrapped in an OpenStruct object; 
+      # the resulting object's <tt>node_value</tt>
+      # attribute points to the original primitive value.
+      
+      attr_accessor_dsl [:nodes, lambda {|v|
+        out=[]
+        v.each_with_index {|d,i|
+          d=OpenStruct.new({:node_value=>d}) unless d.respond_to? :node_value
+          d.index=i
+          out.push(d)
+        }
+        out
+      }]
+      
+      ##
+      # :attr: links
+      #
+      # an array of objects representing links. Objects in
+      # this array must conform to the Rubyvis::Layout::Network::Link interface; at a
+      # minimum, either <tt>source</tt> and <tt>target</tt> indexes or
+      # <tt>source_node</tt> and <tt>target_node</tt> references must be set. 
+      # Note that if the links property is defined after the nodes property, 
+      # the links can be defined in terms of <tt>self.nodes()</tt>.
+
+
+      attr_accessor_dsl [:links, lambda {|v|
+       # out=[]
+        v.map {|d|
+          if !d.link_value.is_a? Numeric
+            d.link_value = !d.value.is_a?(Numeric) ? 1 : d.value
+          end
+          d
+        }
+      }]
+
+      # Resets the cache, such that changes to layout property definitions will be
+      # visible on subsequent render. Unlike normal marks (and normal layouts),
+      # properties associated with network layouts are not automatically re-evaluated
+      # on render; the properties are cached, and any expensive layout algorithms are
+      # only run after the layout is explicitly reset.
+      #
+      # (@returns Rubyvis::Layout::Network) self
+      def reset
+        self._id=Rubyvis.id()
+        self
+      end
+      
+      # @private Skip evaluating properties if cached. */
+      
+      def build_properties(s, properties) # :nodoc:
+        s_id=s._id
+        s_id||=0
+        if (s_id < self._id)
+          layout_build_properties(s,properties)
+        end
+      end
+      
+      def build_implied(s) # :nodoc:
+        network_build_implied(s)
+      end
+      
+      def network_build_implied(s) # :nodoc:
+        layout_build_implied(s)
+        return true if (!s._id.nil? and s._id >= self._id)
+        s._id= self._id
+        
+        s.nodes.each do |d|
+          d.link_degree=0
+        end
+        
+        s.links.each do |d|
+          v=d.link_value
+          if !d.source_node
+            d.source_node=s.nodes[d.source]
+          end
+          d.source_node.link_degree+=v
+          if !d.target_node
+            d.target_node=s.nodes[d.target]
+          end
+          d.target_node.link_degree+=v
+          
+        end
+        false
+      end
+      
+      # Represents a node in a network layout. 
+      # This class mostly  serves to document the attributes that are
+      # used on nodes in network layouts. (Note that hierarchical nodes place
+      # additional requirements on node representation, vis Rubyvis::Dom::Node.)
+      #
+      class Node
+        # The node index, zero-based. This attribute is populated automatically based
+        # on the index in the array returned by the <tt>nodes</tt> property.
+        #
+        # @type number
+        #/
+        attr_accessor :index
+        
+        # The link degree; the sum of link values for all incoming and outgoing links.
+        # This attribute is populated automatically.
+        #
+        # @type number
+        attr_accessor :link_degree
+        
+        # The node name; optional. If present, this attribute will be used to provide
+        # the text for node labels. If not present, the label text will fallback to the
+        # <tt>node_value</tt> attribute.
+        #
+        # @type string
+        attr_accessor :node_name
+        
+        # The node value; optional. If present, and no <tt>node_name</tt> attribute is present, the node value will be used as the label text.
+        # This attribute is also automatically populated if the nodes are specified as an array of 'primitives', such as strings or numbers.
+        attr_accessor :node_value
+      end
+    
+      
+      # Represents a link in a network layout. 
+      # This class mostly serves to document the attributes that are
+      # used on links in network layouts. For hierarchical layouts, this class is
+      # used to represent the parent-child links.
+      #
+      # @see pv.Layout.Network
+      # @name pv.Layout.Network.Link
+      class Link
+        def initialize(opts)
+          @source_node=opts.delete :source_node
+          @target_node=opts.delete :target_node
+          @link_value=opts.delete :link_value
+        end
+        # The link value, or weight; optional. If not specified (or not a number), the
+        # default value of 1 is used.
+        #
+        # @type number
+
+
+        attr_accessor :link_value
+      
+        # The link's source node. If not set, this value will be derived from the
+        # <tt>source</tt> attribute index.
+        #
+        # @type pv.Layout.Network.Node
+
+        attr_accessor :source_node
+        # The link's target node. If not set, this value will be derived from the
+        # <tt>target</tt> attribute index.
+        #
+        # @type pv.Layout.Network.Node
+
+        attr_accessor :target_node
+        # Alias for <tt>sourceNode</tt>, as expressed by the index of the source node.
+        # This attribute is not populated automatically, but may be used as a more
+        # convenient identification of the link's source, for example in a static JSON
+        # representation.
+        #
+        # @type number
+
+        attr_accessor :source
+        # Alias for <tt>targetNode</tt>, as expressed by the index of the target node.
+        # This attribute is not populated automatically, but may be used as a more
+        # convenient identification of the link's target, for example in a static JSON
+        # representation.
+        #
+        # @type number
+
+        attr_accessor :target
+        # Alias for <tt>linkValue</tt>. This attribute is not populated automatically,
+        # but may be used instead of the <tt>linkValue</tt> attribute when specifying
+        # links.
+        #
+        # @type number
+        attr_accessor :value
+      end
+    end
+  end
+end
diff --git a/lib/rubyvis/layout/pack.rb b/lib/rubyvis/layout/pack.rb
new file mode 100644
index 0000000..700593d
--- /dev/null
+++ b/lib/rubyvis/layout/pack.rb
@@ -0,0 +1,332 @@
+module Rubyvis
+  class Layout
+    # Alias for Rubyvis::Layout::Indent
+    def self.Pack
+      Rubyvis::Layout::Pack
+    end
+
+    # Implements a hierarchical layout using circle-packing. The meaning of
+    # the exported mark prototypes changes slightly in the space-filling
+    # implementation:<ul>
+    #
+    # <li><tt>node</tt> - for rendering nodes; typically a Rubyvis::Dot.
+    #
+    # <p><li><tt>link</tt> - unsupported; undefined. Links are encoded implicitly
+    # in the arrangement of the space-filling nodes.
+    #
+    # <p><li><tt>label</tt> - for rendering node labels; typically a
+    # Rubyvis::Label.
+    #
+    # </ul>The pack layout support dynamic sizing for leaf nodes, if a
+    # {@link #size} psuedo-property is specified. The default size function returns
+    # 1, causing all leaf nodes to be sized equally, and all internal nodes to be
+    # sized by the number of leaf nodes they have as descendants.
+    #
+    # <p>The size function can be used in conjunction with the order property,
+    # which allows the nodes to the sorted by the computed size. Note: for sorting
+    # based on other data attributes, simply use the default <tt>null</tt> for the
+    # order property, and sort the nodes beforehand using the {@link pv.Dom}
+    # operator.
+    #
+    # <p>For more details on how to use this layout, see
+    # Rubyvis::Layout::Hierarchy.
+    #
+    # @extends pv.Layout.Hierarchy
+    # @see <a href="http://portal.acm.org/citation.cfm?id=1124772.1124851"
+    # >"Visualization of large hierarchical data by circle packing"</a> by W. Wang,
+    # H. Wang, G. Dai, and H. Wang, ACM CHI 2006.
+    #/
+    class Pack < Hierarchy
+      @properties=Hierarchy.properties.dup
+      def initialize
+        super
+        @node.
+        shape_radius(lambda {|n| n.radius }).
+        stroke_style("rgb(31, 119, 180)").
+        fill_style("rgba(31, 119, 180, 0.25)")
+
+
+        @node_label.text_align("center")
+
+        @link=nil
+
+        @radius = lambda { 1 }
+      end
+
+
+      ##
+      # :attr: spacing
+      # The spacing parameter; defaults to 1, which provides a little bit of padding
+      # between sibling nodes and the enclosing circle. Larger values increase the
+      # spacing, by making the sibling nodes smaller; a value of zero makes the leaf
+      # nodes as large as possible, with no padding on enclosing circles.
+      #
+      # @type number
+
+      ##
+      # :attr: order
+      # The sibling node order. The default order is <tt>null</tt>, which means to
+      # use the sibling order specified by the nodes property as-is. A value of
+      # "ascending" will sort siblings in ascending order of size, while "descending"
+      # will do the reverse. For sorting based on data attributes other than size,
+      # use the default <tt>null</tt> for the order property, and sort the nodes
+      # beforehand using the {@link pv.Dom} operator.
+      #
+      # @see pv.Dom.Node#sort
+
+
+      attr_accessor_dsl :spacing, :order
+
+      ##
+      # Default properties for circle-packing layouts. The default spacing parameter
+      # is 1 and the default order is "ascending".
+      #
+      def self.defaults
+        Rubyvis::Layout::Pack.new.mark_extend(Rubyvis::Layout::Hierarchy.defaults).
+        spacing(1).
+        order("ascending")
+      end
+
+
+      # TODO is it possible for spacing to operate in pixel space?
+      # Right now it appears to be multiples of the smallest radius.
+
+      ##
+      # Specifies the sizing function. By default, a sizing function is disabled and
+      # all nodes are given constant size. The sizing function is invoked for each
+      # leaf node in the tree (passed to the constructor).
+      #
+      # <p>For example, if the tree data structure represents a file system, with
+      # files as leaf nodes, and each file has a <tt>bytes</tt> attribute, you can
+      # specify a size function as:
+      #
+      # <pre>    .size(function(d) d.bytes)</pre>
+      #
+      # As with other properties, a size function may specify additional arguments to
+      # access the data associated with the layout and any enclosing panels.
+      #
+      # @param {function} f the new sizing function.
+      # @returns {pv.Layout.Pack} this.
+      def size(f)
+        if f.is_a? Proc
+          @radius=lambda {|*args| Math.sqrt(f.js_apply(self,args))}
+        else
+          f=Math.sqrt(f)
+          @radius=lambda {f}
+        end
+        self
+      end
+      ## @private Compute the radii of the leaf nodes. #/
+
+      def radii(nodes)
+        stack=Mark.stack
+        stack.unshift(nil)
+        nodes.each {|c|
+          if !c.first_child
+            stack[0]=c
+            c.radius = @radius.js_apply(self, stack)
+          end
+        }
+        stack.shift
+      end
+      def pack_tree(n)
+        nodes = []
+        c=n.first_child
+        while(c)
+          c.radius=pack_tree(c) if c.first_child
+          c.n=c._p=c
+          nodes.push(c)
+          c=c.next_sibling
+        end
+
+        # Sort.
+        case @s.order
+        when "ascending"
+          nodes.sort {|a,b| a.radius<=>b.radius}
+        when 'descending'
+          nodes.sort {|a,b| b.radius<=>a.radius}
+        when 'reverse'
+          nodes.reverse
+        end
+
+        return pack_circle(nodes)
+      end
+      def bound(n)
+        @x_min = [n.x - n.radius, @x_min].min
+        @x_max = [n.x + n.radius, @x_max].max
+        @y_min = [n.y - n.radius, @y_min].min
+        @y_max = [n.y + n.radius, @y_max].max
+      end
+      def insert(a,b)
+        c = a.n
+        a.n = b
+        b._p = a
+        b.n = c
+        c._p = b
+      end
+      def splice(a, b)
+        a.n = b
+        b._p = a
+      end
+      def intersects(a, b)
+        dx = b.x - a.x
+        dy = b.y - a.y
+        dr = a.radius + b.radius
+        (dr * dr - dx * dx - dy * dy) > 0.001 # within epsilon
+      end
+
+      ## @private #/
+      def place(a, b, c)
+        da = b.radius + c.radius
+        db = a.radius + c.radius
+        dx = b.x - a.x
+        dy = b.y - a.y
+        dc = Math.sqrt(dx * dx + dy * dy)
+        cos = (db * db + dc * dc - da * da) / (2.0 * db * dc)
+        theta = Math.acos(cos)
+        x = cos * db
+        h = Math.sin(theta) * db
+        dx = dx/dc
+        dy = dy/dc
+        c.x = a.x + x * dx + h * dy
+        c.y = a.y + x * dy - h * dx
+      end
+
+      # @private #/
+      def transform(n, x, y, k)
+        c=n.first_child
+        while(c) do
+          c.x += n.x
+          c.y += n.y
+          transform(c, x, y, k)
+          c=c.next_sibling
+        end
+        n.x = x + k * n.x
+        n.y = y + k * n.y
+        n.radius *= k
+        n.mid_angle=0 # Undefined on protovis
+      end
+
+
+      def pack_circle(nodes)
+        @x_min = Infinity
+        @x_max = -Infinity
+        @y_min = Infinity
+        @y_max = -Infinity
+        a=b=c=j=k=nil
+
+
+        # Create first node.
+        a = nodes[0];
+        a.x = -a.radius
+        a.y = 0
+        bound(a)
+
+        # Create second node. #/
+        if (nodes.size > 1)
+          b = nodes[1]
+          b.x = b.radius
+          b.y = 0
+          bound(b)
+
+          # Create third node and build chain.
+          if (nodes.size > 2)
+            c = nodes[2]
+            place(a, b, c)
+            bound(c)
+            insert(a, c)
+            a._p = c
+            insert(c, b)
+            b = a.n
+
+            # Now iterate through the rest.
+            i=3
+            while(i < nodes.size) do
+              c=nodes[i]
+              place(a, b, c)
+
+              # Search for the closest intersection. #/
+              isect = 0
+              s1 = 1
+              s2 = 1
+
+              j=b.n
+              while(j!=b) do
+                if (intersects(j, c))
+                  isect=1
+                  break
+                end
+                j=j.n
+                s1+=1
+              end
+
+              if isect==1
+                k=a._p
+                while(k!=j._p) do
+                  if(intersects(k,c))
+                    if(s2 < s1)
+                      isect=-1
+                      j=k
+                    end
+                    break
+                  end
+                  k=k._p
+                  s2+=1
+                end
+              end
+
+
+              # Update node chain. #/
+              if (isect == 0)
+                insert(a, c)
+                b = c
+                bound(c)
+              elsif (isect > 0)
+                splice(a, j)
+                b = j
+                i-=1
+              elsif (isect < 0)
+                splice(j, b)
+                a = j
+                i-=1
+              end
+              i+=1
+            end
+
+
+          end
+        end
+
+        # Re-center the circles and return the encompassing radius. #/
+        cx = (@x_min + @x_max) / 2.0
+        cy = (@y_min + @y_max) / 2.0
+        cr = 0
+        nodes.each do |n|
+          n.x -= cx
+          n.y -= cy
+          cr = [cr, n.radius + Math.sqrt(n.x * n.x + n.y * n.y)].max
+        end
+        cr + @s.spacing
+      end
+
+
+      def build_implied(s)
+        return nil if hierarchy_build_implied(s)
+        @s=s
+        nodes = s.nodes
+        root = nodes[0]
+        radii(nodes)
+
+        # Recursively compute the layout. #/
+        root.x = 0
+        root.y = 0
+        root.radius = pack_tree(root)
+
+        w = self.width
+        h = self.height
+        k = 1.0 / [2.0 * root.radius / w, 2.0 * root.radius / h].max
+        transform(root, w / 2.0, h / 2.0, k)
+      end
+    end
+  end
+end
diff --git a/lib/rubyvis/layout/partition.rb b/lib/rubyvis/layout/partition.rb
new file mode 100644
index 0000000..87a24ec
--- /dev/null
+++ b/lib/rubyvis/layout/partition.rb
@@ -0,0 +1,227 @@
+module Rubyvis
+  class Layout
+    # Alias for Rubyvis::Layout::Partition
+    def self.Partition
+      Rubyvis::Layout::Partition
+    end
+    # Implemeents a hierarchical layout using the partition (or sunburst,
+    # icicle) algorithm. This layout provides both node-link and space-filling
+    # implementations of partition diagrams. In many ways it is similar to
+    # {@link pv.Layout.Cluster}, except that leaf nodes are positioned based on
+    # their distance from the root.
+    #
+    # <p>The partition layout support dynamic sizing for leaf nodes, if a
+    # {@link #size} psuedo-property is specified. The default size function returns
+    # 1, causing all leaf nodes to be sized equally, and all internal nodes to be
+    # sized by the number of leaf nodes they have as descendants.
+    #
+    # <p>The size function can be used in conjunction with the order property,
+    # which allows the nodes to the sorted by the computed size. Note: for sorting
+    # based on other data attributes, simply use the default <tt>null</tt> for the
+    # order property, and sort the nodes beforehand using the {@link pv.Dom}
+    # operator.
+    #
+    # <p>For more details on how to use this layout, see
+    # Rubyvis::Layout::Hierarchy.
+    #
+    # @see pv.Layout.Partition.Fill
+    # @extends pv.Layout.Hierarchy
+    
+    class Partition < Hierarchy
+      include NodeLink
+      @properties=Hierarchy.properties.dup  
+      # Constructs a new, empty partition layout. Layouts are not typically
+      # constructed directly; instead, they are added to an existing panel via
+      # {@link pv.Mark#add}.
+      #      
+      def initialize
+        super
+      end
+      
+      ##
+      # :attr: order
+      # The sibling node order. The default order is <tt>null</tt>, which means to
+      # use the sibling order specified by the nodes property as-is. A value of
+      # "ascending" will sort siblings in ascending order of size, while "descending"
+      # will do the reverse. For sorting based on data attributes other than size,
+      # use the default <tt>null</tt> for the order property, and sort the nodes
+      # beforehand using the {@link pv.Dom} operator.
+      #
+      # @see pv.Dom.Node#sort
+      # @type string
+      
+      ##
+      # :attr: orient
+      # The orientation. The default orientation is "top", which means that the root
+      # node is placed on the top edge, leaf nodes appear at the bottom, and internal
+      # nodes are in-between. The following orientations are supported:<ul>
+      #
+      # <li>left - left-to-right.
+      # <li>right - right-to-left.
+      # <li>top - top-to-bottom.
+      # <li>bottom - bottom-to-top.
+      # <li>radial - radially, with the root at the center.</ul>
+      #
+      # @type string
+      
+      ##
+      # :attr: inner_radius
+      #
+      # The inner radius; defaults to 0. This property applies only to radial
+      # orientations, and can be used to compress the layout radially. Note that for
+      # the node-link implementation, the root node is always at the center,
+      # regardless of the value of this property; this property only affects internal
+      # and leaf nodes. For the space-filling implementation, a non-zero value of
+      # this property will result in the root node represented as a ring rather than
+      # a circle.
+      #
+      # @type number
+      
+      ##
+      # :attr: outer_radius
+      #
+      # The outer radius; defaults to fill the containing panel, based on the height
+      # and width of the layout. If the layout has no height and width specified, it
+      # will extend to fill the enclosing panel.
+      #
+      # @type number
+      
+      attr_accessor_dsl :order, :orient , :inner_radius, :outer_radius
+      
+      # Default properties for partition layouts. The default orientation is "top".
+      def self.defaults
+        Rubyvis::Layout::Partition.new.mark_extend(Rubyvis::Layout::Hierarchy.defaults).
+          orient("top")
+      end
+      def _size(f)
+        if @_size.nil?
+          1
+        else
+          @_size.call(f)
+        end
+      end
+      # Specifies the sizing function. By default, a sizing function is disabled and
+      # all nodes are given constant size. The sizing function is invoked for each
+      # leaf node in the tree (passed to the constructor).
+      #
+      # <p>For example, if the tree data structure represents a file system, with
+      # files as leaf nodes, and each file has a <tt>bytes</tt> attribute, you can
+      # specify a size function as:
+      #
+      # <pre>    .size(function(d) d.bytes)</pre>
+      #
+      # As with other properties, a size function may specify additional arguments to
+      # access the data associated with the layout and any enclosing panels.
+      #
+      # @param {function} f the new sizing function.
+      # @returns {pv.Layout.Partition} this.
+      
+      def size(f=nil,&block)
+        f=block if f.nil?
+        raise "You should pass a proc" if f.nil?
+        @_size=f
+        self
+      end
+      def build_implied(s)
+        partition_build_implied(s)
+      end
+      def partition_build_implied(s)
+        
+        return false if hierarchy_build_implied(s)
+        that = self
+        root = s.nodes[0]
+
+        stack = Rubyvis::Mark.stack
+        max_depth = 0
+
+        # Recursively compute the tree depth and node size. #/
+        stack.unshift(nil)
+        root.visit_after {|n,i| 
+          max_depth=i if i>max_depth
+          if n.first_child
+            n.size = Rubyvis.sum(n.child_nodes, lambda {|v| v.size})
+          else
+            stack[0]=n
+            n.size=that._size(stack[0])
+          end
+          }
+          
+        stack.shift
+        # # Order #/
+        case s.order
+          when 'ascending'
+            root.sort(lambda {|a,b| a.size<=>b.size})
+          when 'descending'
+            root.sort(lambda {|a,b| b.size<=>a.size})
+        end
+        # Compute the unit breadth and depth of each node. #/
+        ds = 1 / max_depth.to_f
+        root.min_breadth = 0
+        root.breadth = 0.5
+        root.max_breadth = 1
+        root.visit_before {|n,i| 
+          b = n.min_breadth
+          ss = n.max_breadth - b
+          c = n.first_child
+          while(c) do
+            c.min_breadth=b
+            b+=(c.size/n.size.to_f)*ss
+            
+            c.max_breadth=b
+            c.breadth=(b+c.min_breadth) / 2.0
+            c=c.next_sibling
+            
+          end
+        }
+        root.visit_after {|n,i|
+          n.min_depth=(i-1)*ds
+          n.max_depth=n.depth=i*ds
+        }
+        
+        node_link_build_implied(s)
+        false
+      end
+      
+      # A variant of partition layout that is space-filling. The meaning of
+      # the exported mark prototypes changes slightly in the space-filling
+      # implementation:<ul>
+      #
+      # <li><tt>node</tt> - for rendering nodes; typically a {@link pv.Bar} for
+      # non-radial orientations, and a {@link pv.Wedge} for radial orientations.
+      #
+      # <p><li><tt>link</tt> - unsupported; undefined. Links are encoded implicitly
+      # in the arrangement of the space-filling nodes.
+      #
+      # <p><li><tt>label</tt> - for rendering node labels; typically a
+      # Rubyvis::Label.
+      #
+      # </ul>For more details on how to use this layout, see
+      # {@link pv.Layout.Partition}.
+      #
+      # @extends pv.Layout.Partition
+
+      
+      class Fill < Partition
+        include Hierarchy::Fill
+        @properties=Partition.properties.dup  
+        
+        # Constructs a new, empty space-filling partition layout. Layouts are not
+        # typically constructed directly; instead, they are added to an existing panel
+        # via {@link pv.Mark#add}.
+        def initialize
+          super
+          fill_constructor
+        end
+        def build_implied(s)
+          return nil if partition_build_implied(s)
+          fill_build_implied(s)
+        end
+        
+        def self.defaults
+          Rubyvis::Layout::Partition::Fill.new.mark_extend(Rubyvis::Layout::Partition.defaults)
+        end
+        
+      end
+    end
+  end
+end
diff --git a/lib/rubyvis/layout/stack.rb b/lib/rubyvis/layout/stack.rb
new file mode 100644
index 0000000..0b38177
--- /dev/null
+++ b/lib/rubyvis/layout/stack.rb
@@ -0,0 +1,307 @@
+module Rubyvis
+  class Layout
+    # Alias for Rubyvis::Layout::Stack 
+    def self.Stack
+      Rubyvis::Layout::Stack
+    end
+    
+    # Implements a layout for stacked visualizations, ranging from simple
+    # stacked bar charts to more elaborate "streamgraphs" composed of stacked
+    # areas. Stack layouts uses length as a visual encoding, as opposed to
+    # position, as the layers do not share an aligned axis.
+    #
+    # <p>Marks can be stacked vertically or horizontally. For example,
+    #
+    #   vis.add(Rubyvis::Layout::Stack)
+    #     .layers([[1, 1.2, 1.7, 1.5, 1.7],
+    #              [.5, 1, .8, 1.1, 1.3],
+    #              [.2, .5, .8, .9, 1]])
+    #     .x(lambda { index * 35})
+    #     .y(lambda {|d| d * 40})
+    #   .layer.add(Rubyvis::Area)
+    #
+    # specifies a vertically-stacked area chart, using the default "bottom-left"
+    # orientation with "zero" offset. This visualization can be easily changed into
+    # a streamgraph using the "wiggle" offset, which attempts to minimize change in
+    # slope weighted by layer thickness. See the offset property for more
+    # supported streamgraph algorithms.
+    #
+    # <p>In the simplest case, the layer data can be specified as a two-dimensional
+    # array of numbers. The <tt>x</tt> and <tt>y</tt> psuedo-properties are used to
+    # define the thickness of each layer at the given position, respectively; in
+    # the above example of the "bottom-left" orientation, the <tt>x</tt> and
+    # <tt>y</tt> psuedo-properties are equivalent to the <tt>left</tt> and
+    # <tt>height</tt> properties that you might use if you implemented a stacked
+    # area by hand.
+    #
+    # <p>The advantage of using the stack layout is that the baseline, i.e., the
+    # <tt>bottom</tt> property is computed automatically using the specified offset
+    # algorithm. In addition, the order of layers can be computed using a built-in
+    # algorithm via the <tt>order</tt> property.
+    #
+    # <p>With the exception of the "expand" <tt>offset</tt>, the stack layout does
+    # not perform any automatic scaling of data; the values returned from
+    # <tt>x</tt> and <tt>y</tt> specify pixel sizes. To simplify scaling math, use
+    # this layout in conjunction with Rubyvis::Scale.linea} or similar.
+    #
+    # <p>In other cases, the <tt>values</tt> psuedo-property can be used to define
+    # the data more flexibly. As with a typical panel & area, the
+    # <tt>layers</tt> property corresponds to the data in the enclosing panel,
+    # while the <tt>values</tt> psuedo-property corresponds to the data for the
+    # area within the panel. For example, given an array of data values:
+    #
+    #   crimea = [
+    #   { date: "4/1854", wounds: 0, other: 110, disease: 110 },
+    #   { date: "5/1854", wounds: 0, other: 95, disease: 105 },
+    #   { date: "6/1854", wounds: 0, other: 40, disease: 95 },
+    #   ...
+    #
+    # and a corresponding array of series names:
+    #
+    #   causes = [:wounds, :other, :disease]
+    #
+    # Separate layers can be defined for each cause like so:
+    #
+    #   vis.add(pv.Layout.Stack)
+    #     .layers(causes)
+    #     .values(crimea)
+    #     .x(lambda {|d| x.scale(d[:date]})
+    #     .y(lambda {|d,dp| y.scale(d[dp])})
+    #   .layer.add(pv.Area)
+    #
+    # As with the panel & area case, the datum that is passed to the
+    # psuedo-properties <tt>x</tt> and <tt>y</tt> are the values (an element in
+    # <tt>crimea</tt>); the second argument is the layer data (a string in
+    # <tt>causes</tt>). Additional arguments specify the data of enclosing panels, if any.
+    class Stack < Rubyvis::Layout
+      @properties=Layout.properties.dup
+      attr_accessor_dsl :orient,:offset, :order, :layers
+      attr_accessor :_x, :_y, :_values, :prop
+
+      def self.defaults
+        Stack.new.mark_extend(Layout.defaults).
+          orient("bottom-left").
+          offset("zero").
+          layers([[]])
+      end
+      
+      # Constructs a new, empty stack layout. Layouts are not typically constructed
+      # directly; instead, they are added to an existing panel via
+      # Rubyvis::Mark.add
+      def initialize
+        super
+        @none=lambda {nil}
+        @prop = {"t"=> @none, "l"=> @none, "r"=> @none, "b"=> @none, "w"=> @none, "h"=> @none}
+        @values=nil
+        @_x=lambda {0}
+        @_y=lambda {0}
+        @_values=Rubyvis.identity
+      end
+      def x(f)
+        @_x=Rubyvis.functor(f)
+        return self
+      end
+      def y(f)
+        @_y=Rubyvis.functor(f)
+        return self
+      end
+      def values(f=nil)
+        if f.nil?
+          return @values
+        else
+          @_values=Rubyvis.functor(f)
+          return self
+        end
+      end
+      
+      
+      def proxy(name)
+        that=self
+        return lambda {
+          a=that.prop[name].js_call(self, self.parent.index, self.index);
+          puts "proxy(#{name}): #{a}" if $DEBUG
+          a
+        }
+      end
+      
+      def build_implied(s)
+        # puts "Build stack" if $DEBUG
+        layout_build_implied(s)
+        data = s.layers
+        n = data.size
+        m = nil
+        orient = s.orient
+        if orient =~/^(top|bottom)\b/
+          horizontal=true
+        else
+          horizontal=false
+        end
+        h = self.parent.send(horizontal ? "height" : "width")
+        x = []
+        y = []
+        dy = []
+        
+        #
+        # Iterate over the data, evaluating the values, x and y functions. The
+        # context in which the x and y psuedo-properties are evaluated is a
+        # pseudo-mark that is a grandchild of this layout.
+        #
+        stack = Rubyvis::Mark.stack
+        
+        o = OpenStruct.new({:parent=> OpenStruct.new({:parent=> self})})
+        stack.unshift(nil)
+        values = []
+        n.times {|i|
+          dy[i] = []
+          y[i] = []
+          o.parent.index = i
+          stack[0] = data[i]
+          values[i] = self._values.js_apply(o.parent, stack)
+          m = values[i].size if (i==0) 
+          stack.unshift(nil)
+          m.times {|j|
+            stack[0] = values[i][j]
+            o.index = j
+            x[j] = self._x.js_apply(o, stack) if i==0
+            dy[i][j] = self._y.js_apply(o, stack)
+          }
+          stack.shift()
+        }
+        stack.shift()
+        
+        # order
+        _index=nil
+        case s.order
+        when "inside-out"
+          
+          max  = dy.map {|v| Rubyvis.max_index(v) }          
+          _map  = Rubyvis.range(n).sort {|a,b| max[a] <=> max[b]}
+          
+          sums = dy.map {|v| Rubyvis.sum(v)}
+          top = 0
+          bottom = 0
+          tops = []
+          bottoms = []
+          
+          n.times {|i|
+            j = _map[i]
+            if (top < bottom) 
+              top += sums[j];
+              tops.push(j);
+            else
+              bottom += sums[j];
+              bottoms.push(j);
+            end
+          }
+          
+          _index = bottoms.reverse+tops
+
+        when "reverse"
+          _index = Rubyvis.range(n - 1, -1, -1)
+        else
+          _index = Rubyvis.range(n)
+        end
+        
+        #/* offset */
+        case (s.offset) 
+        when "silohouette"
+          m.times {|j|
+            o = 0;
+            n.times {|i| 
+              o += dy[i][j]
+            }
+            y[_index[0]][j] = (h - o) / 2.0;
+          }
+        
+        when "wiggle"
+          o = 0;
+          n.times {|i|  o += dy[i][0] }
+          
+          y[_index[0]][0] = o = (h - o) / 2.0
+          
+          (1...m).each  {|j|
+            s1 = 0
+            s2 = 0
+            dx = x[j] - x[j - 1]
+            n.times {|i| s1 += dy[i][j]}
+            n.times {|i|
+              
+              s3 = (dy[_index[i]][j] - dy[_index[i]][j - 1]) / (2.0 * dx)
+              i.times {|k|
+                s3 += (dy[_index[k]][j] - dy[_index[k]][j - 1]) / dx.to_f
+              }
+              s2 += s3 * dy[_index[i]][j]
+            }
+            o -= (s1!=0) ? s2 / s1.to_f * dx : 0
+            y[_index[0]][j] = o
+            
+          }
+        when "expand"
+          m.times {|j|
+            y[_index[0]][j] = 0
+            
+            k = 0
+            n.times {|i| k += dy[i][j]}
+            if (k!=0) 
+              k = h / k.to_f
+              n.times {|i| dy[i][j] *= k}
+            else 
+              k = h / n.to_f
+              n.times {|i| dy[i][j] = k}
+            end
+          }
+        else
+          m.times {|j| y[_index[0]][j] = 0}
+        end
+        
+        # Propagate the offset to the other series. */
+        m.times {|j|
+        o = y[_index[0]][j]
+          (1...n).each {|i|
+            
+            o += dy[_index[i - 1]][j]
+            y[_index[i]][j] = o
+          }
+        }
+        
+        # /* Find the property definitions for dynamic substitution. */
+        
+        i = orient.index("-")
+        pdy = horizontal ? "h" : "w"
+        px = i < 0 ? (horizontal ? "l" : "b") : orient[i + 1,1]
+        py = orient[0,1]
+        
+        
+        @values=values
+        @prop.each {|k,v|
+          @prop[k]=@none
+        }
+        # puts "stack: x:#{px}, y:#{py}, dy:#{pdy}" if $DEBUG
+        @prop[px] =lambda {|i1,j| x[j]}
+        @prop[py] =lambda {|i1,j| y[i1][j]}
+        @prop[pdy]=lambda {|i1,j| dy[i1][j]}  
+      end
+      
+      def layer
+        that=self
+        value = Rubyvis::Mark.new().data(lambda {  that.values[self.parent.index] }).top(proxy("t")).left(proxy("l")).right(proxy("r")).
+          bottom(proxy("b")).
+        width(proxy("w")).
+        height(proxy("h"))
+        
+        class << value # :nodoc:
+          def that=(v)
+            @that = v
+          end
+          def add(type)
+            that  = @that
+            that.add( Rubyvis.Panel ).data(lambda { that.layers() }).add(type).mark_extend( self )
+          end
+        end
+        
+        value.that=self
+        return value
+      end
+    end
+  end
+end
diff --git a/lib/rubyvis/layout/tree.rb b/lib/rubyvis/layout/tree.rb
new file mode 100644
index 0000000..7059fad
--- /dev/null
+++ b/lib/rubyvis/layout/tree.rb
@@ -0,0 +1,267 @@
+module Rubyvis
+  class Layout
+    # Alias for Rubyvis::Layout::Tree 
+    def self.Tree
+      Rubyvis::Layout::Tree
+    end
+    # Implements a node-link tree diagram using the Reingold-Tilford "tidy"
+    # tree layout algorithm. The specific algorithm used by this layout is based on
+    # <a href="http://citeseer.ist.psu.edu/buchheim02improving.html">"Improving
+    # Walker's Algorithm to Run in Linear Time"</A> by C. Buchheim, M. Jünger
+    # & S. Leipert, Graph Drawing 2002. This layout supports both cartesian and
+    # radial orientations orientations for node-link diagrams.
+    #
+    # <p>The tree layout supports a "group" property, which if true causes siblings
+    # to be positioned closer together than unrelated nodes at the same depth. The
+    # layout can be configured using the <tt>depth</tt> and <tt>breadth</tt>
+    # properties, which control the increments in pixel space between nodes in both
+    # dimensions, similar to the indent layout.
+    #
+    # <p>For more details on how to use this layout, see
+    # Rubyvis::Layout::Hierarchy
+    class Tree < Hierarchy
+      @properties=Hierarchy.properties.dup
+      def initialize
+        super
+      end
+      
+      ##
+      # :attr: breadth
+      # The offset between siblings nodes; defaults to 15.
+            
+      ##
+      # :attr: depth
+      # The offset between parent and child nodes; defaults to 60.
+      #
+      
+      ##
+      # :attr: orient
+      # The orientation. The default orientation is "top", which means that the root
+      # node is placed on the top edge, leaf nodes appear at the bottom, and internal
+      # nodes are in-between. The following orientations are supported:<ul>
+      #
+      # <li>left - left-to-right.
+      # <li>right - right-to-left.
+      # <li>top - top-to-bottom.
+      # <li>bottom - bottom-to-top.
+      # <li>radial - radially, with the root at the center.</ul>
+      #
+      
+      ##
+      # :group:
+      # The sibling grouping, i.e., whether differentiating space is placed between
+      # sibling groups. The default is 1 (or true), causing sibling leaves to be
+      # separated by one breadth offset. Setting this to false (or 0) causes
+      # non-siblings to be adjacent.
+      
+      attr_accessor_dsl :group, :breadth, :depth, :orient
+      
+      # Default properties for tree layouts. The default orientation is "top",
+      # the default group parameter is 1, and the default breadth and depth
+      # offsets are 15 and 60 respectively.
+      def self.defaults
+        Rubyvis::Layout::Tree.new.mark_extend(Rubyvis::Layout::Hierarchy.defaults).
+        group(1).
+        breadth(15).
+        depth(60).
+        orient("top")
+      end
+      
+      def first_walk(v)
+        l,r,a=nil,nil,nil
+        if (!v.first_child)
+          l= v.previous_sibling
+          v.prelim = l.prelim + distance(v.depth, true)  if l
+        else    
+          l = v.first_child
+          r = v.last_child
+          a = l # default ancestor
+          v.each_child {|c| 
+            first_walk(c)
+            a = apportion(c, a)
+          }
+          execute_shifts(v)
+          midpoint = 0.5 * (l.prelim + r.prelim)
+          l = v.previous_sibling
+          if l
+            v.prelim = l.prelim + distance(v.depth, true)
+            v.mod = v.prelim - midpoint
+          else
+            v.prelim = midpoint
+          end
+        end
+      end
+      def second_walk(v,m,depth)
+        v.breadth = v.prelim + m
+        m += v.mod
+        v.each_child {|c|
+          second_walk(c, m, depth)
+        }
+      end
+      def apportion(v,a)
+        w = v.previous_sibling
+        if w
+          vip = v
+          vop = v
+          vim = w
+          vom = v.parent_node.first_child
+          sip = vip.mod
+          sop = vop.mod
+          sim = vim.mod
+          som = vom.mod
+          nr = next_right(vim)
+          nl = next_left(vip)
+          while (nr and nl) do
+            vim = nr
+            vip = nl
+            vom = next_left(vom)
+            vop = next_right(vop)
+            vop.ancestor = v
+            shift = (vim.prelim + sim) - (vip.prelim + sip) + distance(vim.depth, false)
+            if (shift > 0)
+              move_subtree(ancestor(vim, v, a), v, shift)
+              sip += shift
+              sop += shift
+            end
+            sim += vim.mod
+            sip += vip.mod
+            som += vom.mod
+            sop += vop.mod
+            nr = next_right(vim)
+            nl = next_left(vip)
+          end
+          
+          if (nr and !next_right(vop))
+            vop.thread = nr
+            vop.mod += sim - sop
+          end
+          if (nl and !next_left(vom))
+            vom.thread = nl
+            vom.mod += sip - som
+            a = v
+          end
+        end
+        a
+      end
+      
+      def next_left(v)
+        v.first_child ? v.first_child : v.thread
+      end
+      def next_right(v)
+        v.last_child ? v.last_child : v.thread
+      end
+      
+      def move_subtree(wm, wp, shift) 
+        subtrees = wp.number - wm.number
+        wp.change -= shift / subtrees.to_f
+        wp.shift += shift
+        wm.change += shift / subtrees.to_f
+        wp.prelim += shift
+        wp.mod += shift
+      end
+      
+      def execute_shifts(v) 
+        shift = 0
+        change = 0
+        c=v.last_child
+        while c        
+          c.prelim += shift
+          c.mod += shift
+          change += c.change
+          shift += c.shift + change
+          c = c.previous_sibling          
+        end
+      end
+      def ancestor(vim, v, a) 
+        (vim.ancestor.parent_node == v.parent_node) ? vim.ancestor : a
+      end
+
+      def distance(depth, siblings) 
+        (siblings ? 1 : (@_group + 1)).to_f / ((@_orient == "radial") ? depth : 1)
+      end
+
+      
+      def mid_angle(n)
+        (@_orient == "radial") ? n.breadth.to_f / depth : 0;
+      end
+      
+      #/** @private */
+      def x(n)
+        case @_orient
+          when "left"
+            n.depth;
+          when "right"
+            @_w - n.depth;
+          when "top"
+            n.breadth + @_w / 2.0
+          when "bottom"
+            n.breadth + @_w / 2.0
+          when "radial"
+            @_w / 2.0 + n.depth * Math.cos(mid_angle(n))
+        end
+      end
+      
+      #/** @private */
+      def y(n)
+        case @_orient
+          when "left"
+            n.breadth + @_h / 2.0
+          when "right"
+            n.breadth + @_h / 2.0
+          when "top"
+            n.depth;
+          when "bottom"
+            @_h - n.depth
+          when "radial"
+            @_h / 2.0 + n.depth * Math.sin(mid_angle(n))
+        end
+      end
+
+      
+      
+      def build_implied(s)
+        return nil if hierarchy_build_implied(s)        
+        @_nodes = s.nodes
+        @_orient = s.orient
+        @_depth = s.depth
+        @_breadth = s.breadth
+        @_group = s.group
+        @_w = s.width
+        @_h = s.height
+        root=@_nodes[0]
+        root.visit_after {|v,i|
+          v.ancestor = v
+          v.prelim = 0
+          v.mod = 0
+          v.change = 0
+          v.shift = 0
+          v.number = v.previous_sibling ? (v.previous_sibling.number + 1) : 0
+          v.depth = i
+        }
+        #/* Compute the layout using Buchheim et al.'s algorithm. */
+        first_walk(root)
+        second_walk(root, -root.prelim, 0)
+        
+        root.visit_after {|v,i|
+          v.breadth *= breadth
+          v.depth *= depth
+          v.mid_angle = mid_angle(v)
+          v.x = x(v)
+          v.y = y(v)
+          v.mid_angle += Math::PI if (v.first_child)
+          v.breadth=nil
+          v.depth=nil
+          v.ancestor=nil
+          v.prelim=nil
+          v.mod=nil
+          v.change=nil
+          v.shift=nil
+          v.number=nil
+          v.thread=nil
+        }
+        
+        
+      end
+    end
+  end
+end
diff --git a/lib/rubyvis/layout/treemap.rb b/lib/rubyvis/layout/treemap.rb
new file mode 100644
index 0000000..ac0daa4
--- /dev/null
+++ b/lib/rubyvis/layout/treemap.rb
@@ -0,0 +1,359 @@
+module Rubyvis
+  class Layout
+    # Alias for Rubyvis::Layout::Treemap
+    def self.Treemap
+      Rubyvis::Layout::Treemap
+    end
+  
+    # Implements a space-filling rectangular layout, with the hierarchy
+    # represented via containment. Treemaps represent nodes as boxes, with child
+    # nodes placed within parent boxes. The size of each box is proportional 
+    # to the size of the node in the tree. This particular algorithm is taken from Bruls,
+    # D.M., C. Huizing, and J.J. van Wijk, <a
+    # href="http://www.win.tue.nl/~vanwijk/stm.pdf">"Squarified Treemaps"</a> in
+    # <i>Data Visualization 2000, Proceedings of the Joint Eurographics and IEEE
+    # TCVG Sumposium on Visualization</i>, 2000, pp. 33-42.
+    #
+    # <p>The meaning of the exported mark prototypes changes slightly in the
+    # space-filling implementation:<ul>
+    #
+    # <li><tt>node</tt> - for rendering nodes; typically a {@link pv.Bar}. The node
+    # data is populated with <tt>dx</tt> and <tt>dy</tt> attributes, in addition to
+    # the standard <tt>x</tt> and <tt>y</tt> position attributes.
+    #
+    # <p><li><tt>leaf</tt> - for rendering leaf nodes only, with no fill or stroke
+    # style by default; typically a Rubyvis::Panel or another layout!
+    #
+    # <p><li><tt>link</tt> - unsupported; undefined. Links are encoded implicitly
+    # in the arrangement of the space-filling nodes.
+    #
+    # <p><li><tt>label</tt> - for rendering node labels; typically a
+    # Rubyvis::Label.
+    #
+    # </ul>For more details on how to use this layout, see
+    # Rubyvis::Layout::Hierarchy.
+    #
+    class Treemap < Hierarchy
+      @properties=Hierarchy.properties.dup
+      def initialize
+        super
+        @size=lambda {|d| d.node_value.to_f}
+        
+        @node.stroke_style("#fff").
+          fill_style("rgba(31, 119, 180, .25)").
+          width(lambda {|n| n.dx}).
+          height(lambda {|n| n.dy })
+        
+        @node_label.
+          visible(lambda {|n| !n.first_child }).
+          left(lambda {|n| n.x + (n.dx / 2.0) }).
+          top(lambda {|n| n.y + (n.dy / 2.0) }).
+          text_align("center").
+          text_angle(lambda {|n| n.dx > n.dy ? 0 : -Math::PI / 2.0 })
+      end
+      
+      def leaf
+        m=Rubyvis::Mark.new.
+        mark_extend(self.node).
+        fill_style(nil).
+        stroke_style(nil).
+        visible(lambda {|n| !n.first_child })
+        m.parent = self
+        m
+      end
+      def link
+        nil
+      end
+      
+      ##
+      # :attr: round
+      # Whether node sizes should be rounded to integer values. This has a similar
+      # effect to setting <tt>antialias(false)</tt> for node values, but allows the
+      # treemap algorithm to accumulate error related to pixel rounding.
+      #
+      # @type boolean
+      
+      
+      
+      ##
+      # :attr: padding_left
+      # The left inset between parent add child in pixels. Defaults to 0.
+      #
+      # @type number
+      # @see #padding
+      
+      
+      
+      ##
+      # :attr: padding_rigth
+      # The right inset between parent add child in pixels. Defaults to 0.
+      #
+      # @type number
+      # @name pv.Layout.Treemap.prototype.paddingRight
+      # @see #padding
+      
+      
+      ##
+      # :attr: padding_top
+      # The top inset between parent and child in pixels. Defaults to 0.
+      #
+      # @type number
+      # @name pv.Layout.Treemap.prototype.paddingTop
+      # @see #padding
+      
+      
+      ##
+      # :attr: padding_bottom      
+      # The bottom inset between parent and child in pixels. Defaults to 0.
+      #
+      # @type number
+      # @name pv.Layout.Treemap.prototype.paddingBottom
+      # @see #padding
+      
+      
+      ##
+      # :attr: mode      
+      # The treemap algorithm. The default value is "squarify". The "slice-and-dice"
+      # algorithm may also be used, which alternates between horizontal and vertical
+      # slices for different depths. In addition, the "slice" and "dice" algorithms
+      # may be specified explicitly to control whether horizontal or vertical slices
+      # are used, which may be useful for nested treemap layouts.
+      #
+      # @type string
+      # @name pv.Layout.Treemap.prototype.mode
+      # @see <a
+      # href="ftp://ftp.cs.umd.edu/pub/hcil/Reports-Abstracts-Bibliography/2001-06html/2001-06.pdf"
+      # >"Ordered Treemap Layouts"</a> by B. Shneiderman & M. Wattenberg, IEEE
+      # InfoVis 2001.
+      
+      
+      ##
+      # :attr: order      
+      # The sibling node order. A <tt>null</tt> value means to use the sibling order
+      # specified by the nodes property as-is; "reverse" will reverse the given
+      # order. The default value "ascending" will sort siblings in ascending order of
+      # size, while "descending" will do the reverse. For sorting based on data
+      # attributes other than size, use the default <tt>null</tt> for the order
+      # property, and sort the nodes beforehand using the {@link pv.Dom} operator.
+      #
+      # @type string
+      # @name pv.Layout.Treemap.prototype.order
+      
+
+      
+      
+      attr_accessor_dsl :round, :padding_left, :padding_right, :padding_top, :padding_bottom, :mode, :order
+      
+      # Default propertiess for treemap layouts. The default mode is "squarify" and the default order is "ascending".
+      def self.defaults
+        Rubyvis::Layout::Treemap.new.mark_extend(Rubyvis::Layout::Hierarchy.defaults).
+        mode("squarify"). # squarify, slice-and-dice, slice, dice
+        order('ascending') # ascending, descending, reverse, nil
+      end
+      
+      # Alias for setting the left, right, top and bottom padding properties
+      # simultaneously.
+      def padding(n)
+        padding_left(n).padding_right(n).padding_top(n).padding_bottom(n)
+      end
+      def _size(d)
+        @size.call(d)
+      end
+     
+      ##
+      # Specifies the sizing function. By default, the size function uses the
+      # +node_value+ attribute of nodes as a numeric value: 
+      # <p>The sizing function is invoked for each leaf node in the tree, per the
+      # <tt>nodes</tt> property. For example, if the tree data structure represents a
+      # file system, with files as leaf nodes, and each file has a <tt>bytes</tt>
+      # attribute, you can specify a size function as:
+      #
+      # <pre>    .size(function(d) d.bytes)</pre>
+      #
+      # @param {function} f the new sizing function.
+      # @returns {pv.Layout.Treemap} this.
+            
+      def size(f)
+        @size=Rubyvis.functor(f)
+        self
+      end
+      
+      
+      def build_implied(s)
+        return nil if hierarchy_build_implied(s)
+        
+        that=self
+        nodes = s.nodes
+        root = nodes[0]
+        stack = Mark.stack
+        
+        left = s.padding_left
+        right = s.padding_right
+        top = s.padding_top
+        bottom = s.padding_bottom
+        left||=0
+        right||=0
+        top||=0
+        bottom||=0
+        size=lambda {|n| n.size}
+        round = s.round ? 
+          lambda {|a| a.round } : 
+          lambda {|a| a.to_f}
+        mode = s.mode
+        
+        slice=lambda { |row, sum, horizontal, x, y, w, h|
+          # puts "slice:#{sum},#{horizontal},#{x},#{y},#{w},#{h}"
+          d=0
+          row.size.times {|i|
+            n=row[i]
+            # puts "i:#{i},d:#{d}"
+            if horizontal
+              n.x = x + d
+              n.y = y
+              d += n.dx = round.call(w * n.size / sum.to_f)
+              n.dy = h
+            else
+              n.x = x
+              n.y = y + d
+              n.dx = w
+              d += n.dy = round.call(h * n.size / sum.to_f)
+            end
+            # puts "n.x:#{n.x}, n.y:#{n.y}, n.dx:#{n.dx}, n.dy:#{n.dy}"
+          }
+          
+         
+          if (row.last)  # correct on-axis rounding error
+            n=row.last
+            if (horizontal) 
+              n.dx += w - d
+            else 
+              n.dy += h - d
+            end
+          end
+        }
+        
+        ratio=lambda {|row, l|
+          rmax = -Infinity
+          rmin = Infinity
+          s = 0
+          row.each_with_index {|v,i|
+            r = v.size
+            rmin = r if (r < rmin)
+            rmax = r if (r > rmax)
+            s += r
+          }
+          s = s * s
+          l = l * l
+          [l * rmax / s.to_f, s.to_f / (l * rmin)].max
+        }
+        
+        layout=lambda {|n,i| 
+          x = n.x + left
+          y = n.y + top
+          w = n.dx - left - right
+          h = n.dy - top - bottom
+          
+          # puts "Layout: '#{n.node_name}', #{n.x}, #{n.y}, #{n.dx}, #{n.dy}"
+          #/* Assume squarify by default. */
+          if (mode != "squarify")
+            slice.call(n.child_nodes, n.size, ( mode == "slice" ? true : mode == "dice" ? false : (i & 1)!=0), x, y, w, h)
+          else
+            row = []
+            mink = Infinity
+            l = [w,h].min
+            k = w * h / n.size.to_f
+            #/* Abort if the size is nonpositive. */
+            
+            if (n.size > 0) 
+              #/* Scale the sizes to fill the current subregion. */
+              n.visit_before {|n1,i1| n1.size *= k }
+              
+              #/** @private Position the specified nodes along one dimension. */
+              position=lambda {|row1| 
+                horizontal = w == l
+                sum = Rubyvis.sum(row1, size)
+                r = l>0 ? round.call(sum / l.to_f) : 0
+                slice.call(row1, sum, horizontal, x, y, horizontal ? w : r, horizontal ? r : h)
+                if horizontal 
+                  y += r
+                  h -= r
+                else
+                  x += r
+                  w -= r
+                end
+                l = [w, h].min
+                horizontal
+              }
+              
+              children = n.child_nodes.dup # copy
+              while (children.size>0) do
+                child = children[children.size - 1]
+                if (child.size==0) 
+                  children.pop
+                  next
+                end
+                row.push(child)
+                
+                k = ratio.call(row, l)
+                
+                if (k <= mink) 
+                  children.pop
+                  mink = k
+                else 
+                  row.pop
+                  position.call(row)
+                  row.clear
+                  mink = Infinity
+                end
+              end
+              
+              #/* correct off-axis rounding error */
+              
+              if (position.call(row))
+                row.each {|v|
+                  v.dy+=h
+                }
+              else
+                row.each {|v|
+                  v.dx+=w
+                }
+              end              
+            end
+          end
+        }
+        
+               
+        stack.unshift(nil)
+        root.visit_after {|nn,i|
+          nn.depth = i
+          nn.x = nn.y = nn.dx = nn.dy = 0
+          if nn.first_child
+            nn.size=Rubyvis.sum(nn.child_nodes, lambda {|v| v.size})
+          else
+            stack[0]=nn
+            nn.size=that._size(stack[0])
+          end
+        }
+        stack.shift()
+        
+        #/* Sort. */
+        
+        case s.order
+          when 'ascending'
+            root.sort(lambda {|a,b| a.size<=>b.size})
+          when 'descending'
+            root.sort(lambda {|a,b| b.size<=>a.size})
+          when 'reverse'
+            root.reverse
+        end
+        # /* Recursively compute the layout. */
+        root.x = 0;
+        root.y = 0;
+        root.dx = s.width
+        root.dy = s.height
+        root.visit_before {|n,i| layout.call(n,i)}
+      end
+      
+    end
+  end
+end
diff --git a/lib/rubyvis/mark.rb b/lib/rubyvis/mark.rb
new file mode 100644
index 0000000..790139e
--- /dev/null
+++ b/lib/rubyvis/mark.rb
@@ -0,0 +1,1095 @@
+module Rubyvis
+  # Constructs a new mark with default properties. Marks, with the exception of
+  # the root panel, are not typically constructed directly; instead, they are
+  # added to a panel or an existing mark via Mark#add
+  #
+  # Represents a data-driven graphical mark. The +Mark+ class is
+  # the base class for all graphical marks in Protovis; it does not provide any
+  # specific rendering functionality, but together with Panel establishes
+  # the core framework.
+  #
+  # Concrete mark types include familiar visual elements such as bars, lines
+  # and labels. Although a bar mark may be used to construct a bar chart, marks
+  # know nothing about charts; it is only through their specification and
+  # composition that charts are produced. These building blocks permit many
+  # combinatorial possibilities.
+  #
+  # Marks are associated with <b>data</b>: a mark is generated once per
+  # associated datum, mapping the datum to visual <b>properties</b> such as
+  # position and color. Thus, a single mark specification represents a set of
+  # visual elements that share the same data and visual encoding. The type of
+  # mark defines the names of properties and their meaning. A property may be
+  # static, ignoring the associated datum and returning a constant; or, it may be
+  # dynamic, derived from the associated datum or index. Such dynamic encodings
+  # can be specified succinctly using anonymous functions. Special properties
+  # called event handlers can be registered to add interactivity.
+  #
+  # Protovis uses <b>inheritance</b> to simplify the specification of related
+  # marks: a new mark can be derived from an existing mark, inheriting its
+  # properties. The new mark can then override properties to specify new
+  # behavior, potentially in terms of the old behavior. In this way, the old mark
+  # serves as the <b>prototype</b> for the new mark. Most mark types share the
+  # same basic properties for consistency and to facilitate inheritance.
+  #
+  # The prioritization of redundant properties is as follows:<ol>
+  #
+  # <li>If the <tt>width</tt> property is not specified (i.e., null), its value
+  # is the width of the parent panel, minus this mark's left and right margins;
+  # the left and right margins are zero if not specified.
+  #
+  # <li>Otherwise, if the <tt>right</tt> margin is not specified, its value is
+  # the width of the parent panel, minus this mark's width and left margin; the
+  # left margin is zero if not specified.
+  #
+  # <li>Otherwise, if the <tt>left</tt> property is not specified, its value is
+  # the width of the parent panel, minus this mark's width and the right margin.
+  #
+  # </ol>This prioritization is then duplicated for the <tt>height</tt>,
+  # <tt>bottom</tt> and <tt>top</tt> properties, respectively.
+  #
+  # While most properties are <i>variable</i>, some mark types, such as lines
+  # and areas, generate a single visual element rather than a distinct visual
+  # element per datum. With these marks, some properties may be <b>fixed</b>.
+  # Fixed properties can vary per mark, but not <i>per datum</i>! These
+  # properties are evaluated solely for the first (0-index) datum, and typically
+  # are specified as a constant. However, it is valid to use a function if the
+  # property varies between panels or is dynamically generated.
+  #
+  # == 'RBP' API
+  # 
+  # Since version 0.2.0, you could use a new API to use marks
+  # , similar to one described on Brown's "Ruby Best Practices".
+  # === Set properties using blocks 
+  # You could use a block to set a property, without using explicitly
+  # lambda statement. So
+  #   area.width {|d| d*20}
+  # is the same as
+  #   area.width lambda {|d| d*20}
+  # === Shortcuts methods
+  # The protovis API uses the chain method aproach. Every method which
+  # set a value on a object returns the same object. I maintain
+  # this approach, and you can do
+  #
+  #   area.width(10).height(20).top(lambda {|d| d*10})
+  #
+  # To add a mark to another, you need to use +add+ method. This methods
+  # returns the new mark, so you can still use the chain methods API,
+  #
+  #   area.width(10).height(20). # object is 'area'
+  #   add(Rubyvis::Label).       # object changed to new label
+  #     text('hi')               # text refers to new label
+  # 
+  # In the spirit of RBP, I created several methods as shortcut for +add+:
+  # area(), bar(), dot(), image(), label(), line(), panel(), rule() and wedge().
+  # If you provide a block, it will be executed inside the context of current of new mark depending on block's parameter.
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Parameter references the new mark
+  # 
+  # ==Example
+  #
+  # *Without parameter*
+  #  vis=Rubyvis::Panel.new do
+  #    area do
+  #      width 10 # width changed for area
+  #      height 10 # height changed for area
+  #    end
+  #  end
+  # 
+  # *Without parameter*
+  #  vis=Rubyvis::Panel.new do
+  #    area do |a|
+  #      width 10 # width changed for panel
+  #      a.height 10 # height changed for area
+  #    end
+  #  end
+  #
+  class Mark
+    # On ruby 1.8, we must delete #id method
+    # Is deprecated, so any good developer should'nt use it....
+    if RUBY_VERSION<"1.9"
+      undef_method :id
+    end
+
+    # Hash storing properties names for current Mark type. 
+    @properties={}
+    
+     # The enclosing parent panel. The parent panel is generally undefined only for the root panel; however, it is possible to create "offscreen" marks that are used only for inheritance purposes.
+    # @attr [Panel]
+    attr_accessor :parent
+    
+    # The root parent panel. This may be undefined for "offscreen" marks that are
+    # created for inheritance purposes only.
+    #
+    # @attr [Panel]
+    attr_accessor :root
+    
+    # The child index. -1 if the enclosing parent panel is nil; otherwise, the
+    # zero-based index of this mark into the parent panel's <tt>children</tt>
+    # array.
+    # @attr [Number]
+    attr_accessor :child_index
+    
+    
+    # The scene graph. The scene graph is an array of objects; each object
+    # (or "node") corresponds to an instance of this mark and an element in the
+    # data array. The scene graph can be traversed to lookup previously-evaluated
+    # properties.
+    attr_accessor :scene
+    
+    # The mark prototype, possibly undefined, from which to inherit property
+    # functions. The mark prototype is not necessarily of the same type as this
+    # mark. Any properties defined on this mark will override properties inherited
+    # either from the prototype or from the type-specific defaults.
+    # @attr [Mark]
+    attr_accessor :proto
+    
+    # The mark anchor target, possibly undefined.
+    # @attr [Mark]
+    attr_accessor :target
+    
+    # The current scale factor, based on any enclosing transforms. The current
+    # scale can be used to create scale-independent graphics. For example, to
+    # define a dot that has a radius of 10 irrespective of any zooming, say:
+    #
+    # <pre>dot.shape_radius(lambda { 10 / self.scale})</pre>
+    #
+    # Note that the stroke width and font size are defined irrespective of scale
+    # (i.e., in screen space) already. Also note that when a transform is applied
+    # to a panel, the scale affects only the child marks, not the panel itself.
+    # @attr [Float]
+    # @see Panel#transform
+    attr_accessor :scale
+    
+    # Array with stores properties values 
+    attr_reader :_properties
+    
+    # OpenStruct which store values for scenes
+    attr_accessor :binds
+
+    
+    # Defines a setter-getter for the specified property.
+    #
+    # If a cast function has been assigned to the specified property name, the
+    # property function is wrapped by the cast function, or, if a constant is
+    # specified, the constant is immediately cast. Note, however, that if the
+    # property value is nil, the cast function is not invoked.
+    # 
+    # Parameters:
+    # * @param [String] name the property name.
+    # * @param [Boolean] +def+ whether is a property or a def.
+    # * @param [Proc] +cast+ the cast function for this property.
+    # * @param [Class] +klass+ the klass on which property will be added
+    
+    def self.property_method(name, _def, func=nil, klass=nil)
+      return if klass.method_defined? name
+      klass.send(:define_method, name) do |*arguments,&block|
+        v=arguments[0]
+        #v,dummy = arguments
+        if block
+          v=block
+        end
+        if _def and self.scene
+          if arguments.size>0
+            defs[name]=OpenStruct.new({:id=>(v.nil?) ? 0 : Rubyvis.id, :value=> v})
+            return self
+          end
+          return defs[name]
+        end
+        
+        if arguments.size>0 or block
+          v=v.to_proc if v.respond_to? :to_proc
+          type=(!_def).to_i<<1 | (v.is_a? Proc).to_i          
+          
+          property_value(name,(type & 1 !=0) ? lambda {|*args|
+              x=v.js_apply(self, args)
+              (func and x) ? func.call(x) : x
+          } : (func and v) ? func.call(v) : v)._type=type
+          #@_properties_types[name]=type
+          return self
+        end
+        i=instance()
+        if i.nil?
+          raise "No instance for #{self} on #{name}"
+        else
+        #          puts "index:#{self.index}, name:#{name}, val:#{i.send(name)}"
+          i.send(name)
+        end
+      end
+      
+      camel=name.to_s.gsub(/(_.)/) {|v| v[1,1].upcase}
+      if camel!=name
+        klass.send(:alias_method, camel, name)
+      end
+    end
+    
+    # Creates a dinamic property using property_method().
+    def self.attr_accessor_dsl(*attr)
+      attr.each  do |sym|
+      if sym.is_a? Array
+        name,func=sym
+      else
+        name=sym
+        func=nil
+      end
+      
+      @properties[name]=true
+      self.property_method(name,false, func, Rubyvis::Mark)        
+      define_method(name.to_s+"=") {|v|
+        self.send(name,v)
+      }
+      end
+    end
+    
+    # Delete index
+    # @private
+    def delete_index
+      @index=nil
+      @index_defined=false
+    end
+    
+    # The mark index. The value of this field depends on which instance (i.e.,
+    # which element of the data array) is currently being evaluated. During the
+    # build phase, the index is incremented over each datum; when handling events,
+    # the index is set to the instance that triggered the event.
+    # @return [Integer]
+    def index
+      if @index.nil?
+        Mark.index
+      else
+        @index
+      end
+    end
+    # Returns true if index attribute is set and not deleted
+    def index_defined?
+      @index_defined
+    end
+    # Set index attribute.
+    def index=(v)
+      @index_defined=true
+      @index=v
+      v
+    end
+    
+    # Sets the value of the property <i>name</i> to <i>v</i>    
+    def property_value(name,v)
+      prop=Property.new({:name=>name, :id=>Rubyvis.id, :value=>v})
+      @_properties.delete_if{|v1| v1.name==name}
+      @_properties.push(prop)
+      #@_properties_values[name]=v
+      prop
+    end
+    
+    # Alias for setting the left, right, top and bottom properties simultaneously.
+    # 
+    # @see Mark#left
+    # @see Mark#right
+    # @see Mark#top
+    # @see Mark#bottom
+    # @return [Mark] self
+    def margin(n)
+      self.left(n).right(n).top(n).bottom(n)
+    end
+    
+    
+    # Returns the current instance of this mark in the scene graph.
+    # This is typically equivalent to +self.scene[self.index]+, however if the scene or index is unset, the default instance of the mark is returned. If no default is set, the default is the last instance. 
+    # Similarly, if the scene or index of the parent panel is unset, the default instance of this mark in the last instance of the enclosing panel is returned, and so on.
+    #
+    # @return a node in the scene graph.
+    def instance(default_index=nil)
+      scene=self.scene
+      scene||=self.parent.instance(-1).children[self.child_index]
+      
+      index = !self.index.nil? ? self.index : default_index
+      
+      #puts "defined?: #{index_defined?} : type: #{type}, self.index: #{self.index}, default_index: #{default_index}, index:#{index}"
+      scene[index < 0 ? scene.size-1: index]
+    end
+
+    ##
+    # :section: Marks properties
+    ##
+    
+    ##
+    # :attr: data
+    # The data property; an array of objects. The size of the array determines the number of marks that will be instantiated; each element in the array will be passed to property functions to compute the property values. Typically, the data property is specified as a constant array, such as
+    #   m.data([1, 2, 3, 4, 5])
+    # However, it is perfectly acceptable to define the data property as a
+    # proc. This function might compute the data dynamically, allowing
+    # different data to be used per enclosing panel. For instance, in the stacked
+    # area graph example (see Mark#scene), the data function on the area mark
+    # dereferences each series.
+    
+    ##
+    # :attr: visible
+    # The visible property; a boolean determining whether or not the mark instance
+    # is visible. If a mark instance is not visible, its other properties will not
+    # be evaluated. Similarly, for panels no child marks will be rendered.
+    
+    ##
+    # :attr: left
+    # The left margin; the distance, in pixels, between the left edge of the
+    # enclosing panel and the left edge of this mark. Note that in some cases this
+    # property may be redundant with the right property, or with the conjunction of
+    # right and width.
+    
+    ##
+    # :attr: right
+    # The right margin; the distance, in pixels, between the right edge of the
+    # enclosing panel and the right edge of this mark. Note that in some cases this
+    # property may be redundant with the left property, or with the conjunction of
+    # left and width.
+    
+    ##
+    # :attr: top
+    # The top margin; the distance, in pixels, between the top edge of the
+    # enclosing panel and the top edge of this mark. Note that in some cases this
+    # property may be redundant with the bottom property, or with the conjunction
+    # of bottom and height.
+    
+    ##
+    # :attr: bottom
+    # The bottom margin; the distance, in pixels, between the bottom edge of the
+    # enclosing panel and the bottom edge of this mark. Note that in some cases
+    # this property may be redundant with the top property, or with the conjunction
+    # of top and height.
+    
+    ##
+    # :attr: cursor
+    # The cursor property; corresponds to the CSS cursor property. This is
+    # typically used in conjunction with event handlers to indicate interactivity.
+    # See {CSS 2 cursor}[http://www.w3.org/TR/CSS2/ui.html#propdef-cursor]
+    
+    ##
+    # :attr: title
+    # The title property; corresponds to the HTML/SVG title property, allowing the
+    # general of simple plain text tooltips.
+    
+    
+    ##
+    # :attr: events
+    # The events property; corresponds to the SVG pointer-events property,
+    # specifying how the mark should participate in mouse events. The default value
+    # is "painted". Supported values are:
+    #
+    # <p>"painted": The given mark may receive events when the mouse is over a
+    # "painted" area. The painted areas are the interior (i.e., fill) of the mark
+    # if a 'fillStyle' is specified, and the perimeter (i.e., stroke) of the mark
+    # if a 'strokeStyle' is specified.
+    #
+    # <p>"all": The given mark may receive events when the mouse is over either the
+    # interior (i.e., fill) or the perimeter (i.e., stroke) of the mark, regardless
+    # of the specified fillStyle and strokeStyle.
+    #
+    # <p>"none": The given mark may not receive events.
+    
+    ##
+    # :attr: reverse
+    # The reverse property; a boolean determining whether marks are ordered from
+    # front-to-back or back-to-front. SVG does not support explicit z-ordering;
+    # shapes are rendered in the order they appear. Thus, by default, marks are
+    # rendered in data order. Setting the reverse property to false reverses the
+    # order in which they are rendered; however, the properties are still evaluated
+    # (i.e., built) in forward order.
+    
+    ##
+    # :attr: id
+    # The instance identifier, for correspondence across animated transitions. If
+    # no identifier is specified, correspondence is determined using the mark
+    # index. Identifiers are not global, but local to a given mark.
+    
+    #
+    
+    attr_accessor_dsl :data, :visible, :left, :right, :top, :bottom, :cursor, :title, :reverse, :antialias, :events, :id
+
+    @scene=nil
+    @stack=[]
+    @index=nil
+
+    # @private Records which properties are defined on this mark type.
+    def self.properties
+      @properties
+    end
+    # Common index for all marks
+    def Mark.index
+      @index
+    end
+    
+    # Set common index for all marks    
+    def Mark.index=(v)
+      @index=v
+    end
+    # Get common scene for all marks    
+    def self.scene
+      @scene
+    end
+    # Set common scene for all marks        
+    def self.scene=(v)
+      @scene=v
+    end
+    
+    
+    # Return properties for current mark
+    def properties
+      (self.class).properties
+    end
+    # Get common stack for all marks    
+    def Mark.stack
+      @stack
+    end
+    # Set common stack for all marks        
+    def Mark.stack=(v)
+      @stack=v
+    end
+
+    # Create a new Mark
+    def initialize(opts=Hash.new, &block)
+      @_properties=[]
+      opts.each {|k,v|
+        self.send("#{k}=",v) if self.respond_to? k
+      }
+      @defs={}
+      @child_index=-1
+      @index=-1
+      @index_defined = true
+      @scale=1
+      @scene=nil
+      if block
+        execute(&block)
+        #block.arity<1 ? self.instance_eval(&block) : block.call(self)
+      end
+    end
+    # Execute a block using this mark as a reference
+    # <b>Example</b>
+    #   bar.execute |b|
+    #     b.width 10
+    #     b.add(Rubyvis::Label)
+    #   end
+    def execute(&block)
+      block.arity<1 ? self.instance_eval(&block) : block.call(self)      
+    end
+    # The mark type; a lower name. The type name controls rendering
+    # behavior, and unless the rendering engine is extended, must be one of the
+    # built-in concrete mark types: area, bar, dot, image, label, line, panel,
+    # rule, or wedge.
+    def type
+      "mark"
+    end
+    
+    # Default properties for all mark types. By default, the data array is the
+    # parent data as a single-element array; if the data property is not
+    # specified, this causes each mark to be instantiated as a singleton 
+    # with the parents  datum. The visible property is true by default, 
+    # and the reverse property is false.    
+    def self.defaults
+      Mark.new({:data=>lambda {|d| [d]}, :visible=>true, :antialias=>true, :events=>'painted'})
+    end
+    
+    # Sets the prototype of this mark to the specified mark. Any properties not
+    # defined on this mark may be inherited from the specified prototype mark,
+    # or its prototype, and so on. The prototype mark need not be the same 
+    # type of mark as this mark. (Note that for inheritance to be useful,
+    # properties with the same name on different mark types should 
+    # have equivalent meaning).
+    # On protovis, this method is called +extend+, but it should be changed
+    # because clashed with native +extend+ method
+    def mark_extend(proto)
+      @proto=proto
+      @target=proto.target
+      self
+    end
+    # Find the instances of this mark that match source.
+    # @see Anchor
+    def instances(source)
+      mark = self
+      _index = []
+      scene=nil
+      
+      while (!(scene = mark.scene)) do
+        source = source.parent;
+        _index.push(OpenStruct.new({:index=>source.index, :child_index=>mark.child_index}))
+        mark = mark.parent
+      end
+
+      while (_index.size>0) do
+        i = _index.pop()
+        scene = scene[i.index].children[i.child_index]
+      end
+      #
+      # When the anchor target is also an ancestor, as in the case of adding
+      # to a panel anchor, only generate one instance per panel. Also, set
+      # the margins to zero, since they are offset by the enclosing panel.
+      # /
+      
+      if (index_defined?)
+        s = scene[self.index].dup
+        s.right = s.top = s.left = s.bottom = 0;
+        return [s];
+      end
+      scene
+    end
+    
+
+    # Returns the first instance of this mark in the scene graph. This
+    # method can only be called when the mark is bound to the scene graph (for
+    # example, from an event handler, or within a property function).
+    #
+    # * @returns a node in the scene graph.
+    def first 
+      scene[0]
+    end
+    # Returns the last instance of this mark in the scene graph. This
+    # method can only be called when the mark is bound to the scene graph (for
+    # example, from an event handler, or within a property function). In addition,
+    # note that mark instances are built sequentially, so the last instance of this
+    # mark may not yet be constructed.
+    #
+    # * @returns a node in the scene graph.
+    def last 
+      scene[scene.size - 1]
+    end
+    
+        
+    # Returns the previous instance of this mark in the scene graph, or
+    # nil if this is the first instance.
+    #
+    # @return a node in the scene graph, or nil.
+    def sibling
+      (self.index==0) ? nil: self.scene[self.index-1]
+    end
+    
+    
+    # Returns the current instance in the scene graph of this mark,
+    # in the previous instance of the enclosing parent panel. 
+    # May return nil if this instance could not be found.
+    #
+    # @return a node in the scene graph, or nil.
+    def cousin
+      par=self.parent
+      s= par ? par.sibling : nil
+      (s and s.children) ? s.children[self.child_index][self.index] : nil
+    end
+    
+    # Adds a new mark of the specified type to the enclosing parent panel,
+    # whilst simultaneously setting the prototype of the new mark 
+    # to be this mark.
+    #
+    # * @param {function} type the type of mark to add; a constructor, such as
+    # +Rubyvis::Bar+
+    # * @returns {Mark} the new mark.
+    # * @see #mark_extend
+    def add(type)
+      parent.add(type).mark_extend(self)
+    end
+    # Returns an anchor with the specified name. All marks support the five
+    # standard anchor names:
+    # * top
+    # * left
+    # * center
+    # * bottom
+    # * right
+    #
+    # In addition to positioning properties (left, right, top bottom), the
+    # anchors support text rendering properties (text-align, text-baseline).
+    # Text is rendered to appear inside the mark by default.
+    #
+    # To facilitate stacking, anchors are defined in terms of their opposite
+    # edge. For example, the top anchor defines the bottom property, 
+    # such that the mark extends upwards; the bottom anchor instead defines 
+    # the top property, such that the mark extends downwards. See also Layout::Stack
+    #
+    # While anchor names are typically constants, the anchor name is a true
+    # property, which means you can specify a function to compute the anchor name
+    # dynamically. See the Anchor#name property for details.
+    #
+    # @param [String] name the anchor name; either a string or a property function.
+    # @return [Anchor] the new anchor.
+    def anchor(name='center')
+      mark_anchor(name)
+    end
+    # Implementation of mark anchor
+    def mark_anchor(name="center") # :nodoc:
+      anchor=Rubyvis::Anchor.
+        new(self).
+        name(name).
+        data(lambda {
+          pp self.scene.target if $DEBUG
+          a=self.scene.target.map {|s| puts "s:#{s.data}" if $DEBUG; s.data}
+          p a if $DEBUG
+          a 
+        }).visible(lambda {
+          
+          self.scene.target[index].visible
+        }).id(lambda {
+            self.scene.target[index].id
+        }).
+        left(lambda {
+          s = self.scene.target[index]
+          w = s.width
+          w||=0
+          if ['bottom','top','center'].include?(self.name)
+            s.left + w / 2.0
+          elsif self.name=='left'
+            nil
+          else
+            s.left + w
+          end
+        }).
+        top(lambda {
+        s = self.scene.target[self.index]
+        h = s.height
+        h||= 0
+        if ['left','right','center'].include? self.name
+          s.top+h/2.0
+        elsif self.name=='top'
+          nil
+        else
+          s.top + h
+        end
+      }).right(lambda {
+        s = self.scene.target[self.index]
+        self.name() == "left" ? s.right + (s.width ? s.width : 0) : nil;
+      }).bottom(lambda {
+        s = self.scene.target[self.index];
+        self.name() == "top" ? s.bottom + (s.height ? s.height : 0) : nil;
+      }).text_align(lambda {
+        if ['bottom','top','center'].include? self.name
+          'center'
+        elsif self.name=='right'
+          'right'
+        else
+          'left'
+        end
+      }).text_baseline(lambda {
+
+        if ['right','left','center'].include? self.name
+          'middle'
+        elsif self.name=='top'
+          'top'
+        else
+          'bottom'
+        end
+      })
+      anchor
+    end
+
+
+    # Computes the implied properties for this mark for the specified
+    # instance <tt>s</tt> in the scene graph. Implied properties are those with
+    # dependencies on multiple other properties; for example, the width property
+    # may be implied if the left and right properties are set. This method can be
+    # overridden by concrete mark types to define new implied properties, if
+    # necessary.
+    #
+    # @param s a node in the scene graph; the instance of the mark to build.
+    def build_implied(s) # :nodoc:
+      mark_build_implied(s)
+    end
+    
+    def mark_build_implied(s) # :nodoc:
+      l=s.left
+      r=s.right
+      t=s.top
+      b=s.bottom
+      prop=self.properties
+      
+      #p self
+      
+      w = (prop[:width])  ? s.width : 0
+      h = (prop[:height])  ? s.height : 0
+      
+      width=self.parent ? self.parent.width() : (w+(l.nil? ? 0 : l)+(r.nil? ? 0 : r))
+      #puts (self.parent)? "parent width: #{self.parent.width}" : "no parent" if $DEBUG
+      #p prop.sort if $DEBUG
+      
+      height=self.parent ? self.parent.height(): (h+(t.nil? ? 0 : t )+(b.nil? ? 0 : b))
+      
+      puts "build implied #{type}: l:#{l},r:#{r},t:#{t},b:#{b}, w:#{prop[:width]} #{w},h: #{prop[:height]} #{h}, width:#{width}, height:#{height}" if $DEBUG
+      
+      if w.nil?
+        r||=0
+        l||=0
+        w=width-r-l
+      elsif r.nil?
+        if l.nil?
+          r=(width-w) / (2.0)
+          l=r
+        else
+          r=width-w-l
+        end
+      elsif l.nil?
+        l=width-w-r
+      end
+
+      
+
+      if h.nil?
+        t||=0
+        b||=0
+        h=height-t-b
+      elsif b.nil?
+        if t.nil?
+          t=(height-h) / 2.0
+          b=t
+        else
+          b=height-h-t
+        end
+      elsif t.nil?
+        t=height-h-b
+      end
+
+
+
+      s.left=l
+      s.right=r
+      s.top=t
+      s.bottom=b
+
+      puts "Post->left: #{l},right:#{r},top:#{t},bottom:#{b}, width:#{w}, height:#{h}\n\n" if $DEBUG
+      s.width  = w if prop[:width]
+      s.height = h if prop[:height]
+      s.text_style=Rubyvis::Color.transparent if prop[:text_style] and !s.text_style
+      s.fill_style=Rubyvis::Color.transparent if prop[:fill_style] and !s.fill_style
+      s.stroke_style=Rubyvis::Color.transparent if prop[:stroke_style] and !s.stroke_style
+    end
+    # Renders this mark, including recursively rendering all child marks if this is
+    # a panel. This method finds all instances of this mark and renders them. This
+    # method descends recursively to the level of the mark to be rendered, finding
+    # all visible instances of the mark. After the marks are rendered, the scene
+    # and index attributes are removed from the mark to restore them to a clean
+    # state.
+    #
+    # <p>If an enclosing panel has an index property set (as is the case inside in
+    # an event handler), then only instances of this mark inside the given instance
+    # of the panel will be rendered; otherwise, all visible instances of the mark
+    # will be rendered.
+    def render
+      parent=self.parent
+      @stack=Mark.stack
+      if parent and !self.root.scene
+        root.render()
+        return
+      end
+      @indexes=[]
+      mark=self
+      until mark.parent.nil?
+        @indexes.unshift(mark.child_index)
+      end
+      bind
+      while(parent and !parent.respond_to? :index) do
+        parent=parent.parent
+      end
+
+      self.context( parent ? parent.scene : nil,
+        parent ? parent.index : -1,
+        lambda { render_render(root, 0,1) }
+        )
+
+    end
+
+    def render_render(mark,depth,scale) # :nodoc:
+      mark.scale=scale
+      if (depth < @indexes.size)
+        @stack.unshift(nil)
+        if (mark.index_defined?)
+          render_instance(mark, depth, scale);
+        else
+          mark.scene.size.times {|i|
+            mark.index = i;
+            render_instance(mark, depth, scale);
+          }
+          mark.delete_index
+        end
+        stack.shift
+      else
+        mark.build
+        Rubyvis::SvgScene.scale = scale;
+        Rubyvis::SvgScene.update_all(mark.scene);
+      end
+      mark.scale=nil
+    end
+    
+    
+    def render_instance(mark,depth,scale) # :nodoc:
+      s=mark.scene[mark.index]
+      if s.visible
+        child_index=@indexes[depth]
+        child=mark.children[child_index]
+        child_index.times {|i|
+          mark.children[i].scene=s.children[i]
+        }
+        Mark.stack[0]=s.data
+
+        if (child.scene)
+          render_render(child,depth+1,scale*s.transform.k)
+        else
+          child.scene=s.children[child_index]
+          render_render(child, depth+1,scale*s.transform.k)
+          child.scene=nil
+        end
+        child_index.times {|i|
+          mark.children[i].scene=nil
+        }
+
+      end
+    end
+    def bind_bind(mark)
+      begin
+        #puts "Binding:#{mark.type}->#{mark._properties.map {|v| v.name}}"
+        
+        mark._properties.reverse.each {|v|
+          
+          #p v.name
+          k=v.name
+          if !@seen.has_key?(k)
+            @seen[k]=v
+            case k
+            when :data
+              @_data=v
+            when :visible
+              @_required.push(v)
+            when :id
+              @_required.push(v)
+            else
+              @types[v._type].push(v)
+            end
+          end
+        }
+      end while(mark = mark.proto)
+    end
+    private :bind_bind, :render_render, :render_instance
+    # @private In the bind phase, inherited property definitions are cached so they
+    # do not need to be queried during build.
+    def bind
+      mark_bind
+    end
+    
+    def mark_bind() # :nodoc:
+      @seen={}
+      @types={1=>[],2=>[],3=>[]}
+      @_data=nil
+      @_required=[]
+      #puts "Binding!"
+      bind_bind(self)
+      bind_bind((self.class).defaults)
+      @types[1].reverse!
+      @types[3].reverse!
+      #puts "***"
+      #pp @types[3]
+      #puts "***"
+      mark=self
+      begin
+        properties.each {|name,v|
+          if !@seen[name]
+            @seen[name]=Property.new(:name=>name, :_type=>2, :value=>nil)
+            @types[2].push(@seen[name])
+          end
+        }
+      end while(mark = mark.proto)
+      @binds=OpenStruct.new({:properties=>@seen, :data=>@_data, :required=>@_required, :optional=>@types[1]+ at types[2]+ at types[3]
+      })
+    end
+
+
+    def context_apply(scene,index) # :nodoc:
+      Mark.scene=scene
+      Mark.index=index
+      return if(!scene)
+      that=scene.mark
+      mark=that
+      ancestors=[]
+      begin
+        ancestors.push(mark)
+        Mark.stack.push(scene[index].data)
+        mark.index=index
+        mark.scene=scene
+        index=scene.parent_index
+        scene=scene.parent
+      end while(mark=mark.parent)
+      k=1
+      ancestors.size.times {|ic|
+        i=ancestors.size-ic-1
+        mark=ancestors[i]
+        mark.scale=k
+        k=k*mark.scene[mark.index].transform.k
+      }
+      if (that.children)
+        n=that.children.size
+        n.times {|i|
+          mark=that.children[i]
+          mark.scene=that.scene[that.index].children[i]
+          mark.scale=k
+        }
+
+      end
+
+    end
+    def context_clear(scene,index) # :nodoc:
+      return if !scene
+      that=scene.mark
+      mark=nil
+      if(that.children)
+        that.children.size.times {|i|
+          mark=that.children[i]
+          mark.scene=nil
+          mark.scale=nil
+        }
+
+      end
+      mark=that
+      begin
+        Mark.stack.pop
+        if(mark.parent)                 
+          mark.scene=nil
+          mark.scale=nil
+        end
+        mark.index=nil
+      end while(mark=mark.parent)
+    end
+    def context(scene, index, f) # :nodoc:
+      #proto=Mark
+      stack=Mark.stack
+      oscene=Mark.scene
+      oindex=Mark.index
+      context_clear(oscene,oindex)
+      context_apply(scene,index)
+      begin
+        f.js_apply(self, stack)
+      ensure
+        context_clear(scene,index)
+        context_apply(oscene,oindex)
+      end
+    end
+
+    # Evaluates properties and computes implied properties. Properties are
+    # stored in the Mark.scene array for each instance of this mark.
+    #
+    # As marks are built recursively, the Mark.index property is updated to
+    # match the current index into the data array for each mark. Note that the
+    # index property is only set for the mark currently being built and its
+    # enclosing parent panels. The index property for other marks is unset, but is
+    # inherited from the global +Mark+ class prototype. This allows mark
+    # properties to refer to properties on other marks <i>in the same panel</i>
+    # conveniently; however, in general it is better to reference mark instances
+    # specifically through the scene graph rather than depending on the magical
+    # behavior of Mark#index.
+    #
+    # The root scene array has a special property, <tt>data</tt>, which stores
+    # the current data stack. The first element in this stack is the current datum,
+    # followed by the datum of the enclosing parent panel, and so on. The data
+    # stack should not be accessed directly; instead, property functions are passed
+    # the current data stack as arguments.
+    #
+    # <p>The evaluation of the <tt>data</tt> and <tt>visible</tt> properties is
+    # special. The <tt>data</tt> property is evaluated first; unlike the other
+    # properties, the data stack is from the parent panel, rather than the current
+    # mark, since the data is not defined until the data property is evaluated.
+    # The <tt>visible</tt> property is subsequently evaluated for each instance;
+    # only if true will the {@link #buildInstance} method be called, evaluating
+    # other properties and recursively building the scene graph.
+    #
+    # <p>If this mark is being re-built, any old instances of this mark that no
+    # longer exist (because the new data array contains fewer elements) will be
+    # cleared using {@link #clearInstance}.
+    #
+    # @param parent the instance of the parent panel from the scene graph.
+    def build
+      scene=self.scene
+      stack=Mark.stack
+      if(!scene)
+        self.scene=SceneElement.new
+        scene=self.scene
+        scene.mark=self
+        scene.type=self.type
+        scene.child_index=self.child_index
+        if(self.parent)
+          scene.parent=self.parent.scene
+          scene.parent_index=self.parent.index
+        end
+      end
+      # Resolve anchor target
+      #puts "Resolve target"
+      if(self.target)
+        scene.target=self.target.instances(scene)
+      end
+      #pp self.binds
+      data=self.binds.data
+      #puts "stack:#{stack}"
+      #puts "data_value:#{data.value}"
+
+      data=(data._type & 1)>0 ? data.value.js_apply(self, stack) : data.value
+      #puts "data:#{data}"
+
+      stack.unshift(nil)
+      scene.size=data.size
+      data.each_with_index {|d, i|
+        Mark.index=i
+        self.index=i
+        s=scene[i]
+        if !s
+          scene[i]=s=SceneElement.new
+        end
+        stack[0]=data[i]
+        s.data=data[i]
+        build_instance(s)
+      }
+      Mark.index=-1
+      delete_index
+      stack.shift()
+      self
+    end
+    # @private
+    def build_instance(s) # :nodoc:
+      mark_build_instance(s)
+    end
+    # @private
+    def mark_build_instance(s1) # :nodoc:
+      build_properties(s1, self.binds.required)
+      if s1.visible
+        build_properties(s1, self.binds.optional)
+        build_implied(s1)
+      end
+    end
+    
+    # Evaluates the specified array of properties for the specified
+    # instance <tt>s</tt> in the scene graph.
+    #
+    # @param s a node in the scene graph; the instance of the mark to build.
+    # @param properties an array of properties.
+    
+    def build_properties(ss,props) # :nodoc:
+      mark_build_properties(ss,props)
+    end
+    
+    def mark_build_properties(ss, props) # :nodoc:
+      #p "#{type}:"+props.map {|prop| prop.name}.join(",")
+      props.each do |prop|
+        v=prop.value
+        # p "#{prop.name}=#{v}"
+        if prop._type==3
+          v=v.js_apply(self, Mark.stack)
+        end
+        ss.send((prop.name.to_s+"=").to_sym, v)
+      end
+    end
+    
+    # @todo implement
+    def event(type,handler) # :nodoc:
+      #@_handlers[type]=handler
+      self
+    end
+  end
+end
+
+require 'rubyvis/mark/anchor'
+require 'rubyvis/mark/bar'
+require 'rubyvis/mark/image'
+require 'rubyvis/mark/panel'
+require 'rubyvis/mark/area'
+require 'rubyvis/mark/line'
+require 'rubyvis/mark/rule'
+require 'rubyvis/mark/label'
+require 'rubyvis/mark/dot'
+require 'rubyvis/mark/wedge'
+
diff --git a/lib/rubyvis/mark/anchor.rb b/lib/rubyvis/mark/anchor.rb
new file mode 100644
index 0000000..65d8c42
--- /dev/null
+++ b/lib/rubyvis/mark/anchor.rb
@@ -0,0 +1,83 @@
+module Rubyvis
+  # Alias por Rubyvis::Anchor.new(target)
+  def self.Anchor(target)
+    Rubyvis::Anchor.new(target)
+  end
+  # Represents an anchor on a given mark. An anchor is itself a mark, but
+  # without a visual representation. It serves only to provide useful default
+  # properties that can be inherited by other marks. Each type of mark can define
+  # any number of named anchors for convenience. If the concrete mark type does
+  # not define an anchor implementation specifically, one will be inherited from
+  # the mark's parent class.
+  #
+  # For example, the bar mark provides anchors for its four sides: left,
+  # right, top and bottom. Adding a label to the top anchor of a bar,
+  #
+  #   bar.anchor("top").add(Rubyvis::Label)
+  #
+  # will render a text label on the top edge of the bar; the top anchor defines
+  # the appropriate position properties (top and left), as well as text-rendering
+  # properties for convenience (text_align and text_baseline).
+  #
+  # <p>Note that anchors do not <i>inherit</i> from their targets; the positional
+  # properties are copied from the scene graph, which guarantees that the anchors
+  # are positioned correctly, even if the positional properties are not defined
+  # deterministically. (In addition, it also improves performance by avoiding
+  # re-evaluating expensive properties.) If you want the anchor to inherit from
+  # the target, use Mark#extend before adding. For example:
+  #
+  #   bar.anchor("top").extend(bar).add(Rubyvis::Label)
+  #
+  # The anchor defines it's own positional properties, but other properties (such
+  # as the title property, say) can be inherited using the above idiom. Also note
+  # that you can override positional properties in the anchor for custom
+  # behavior.
+  class Anchor < Mark
+    # List of properties common to all Anchors
+    @properties=Mark.properties.dup
+    
+    ##
+    # :attr: name
+    # The anchor name. The set of supported anchor names is dependent on the
+    # concrete mark type; see the mark type for details. For example, bars support
+    # left, right, top and bottom anchors.
+    #
+    # While anchor names are typically constants, the anchor name is a true
+    # property, which means you can specify a function to compute the anchor name
+    # dynamically. For instance, if you wanted to alternate top and bottom anchors, saying
+    #
+    #   m.anchor(lambda {(index % 2) ? "top" : "bottom"}).add(Rubyvis::Dot)
+    #
+    # would have the desired effect.
+    
+    #
+    attr_accessor_dsl [:name, lambda {|d| d.to_s}]
+    
+    # Create a new Anchor. Use Mark.add instead.
+    
+    def initialize(target)
+      
+      self.target=target
+      self.parent=target.parent
+      super()
+    end
+    
+    # Sets the prototype of this anchor to the specified mark. Any properties not
+    # defined on this mark may be inherited from the specified prototype mark, or
+    # its prototype, and so on. The prototype mark need not be the same type of
+    # mark as this mark. (Note that for inheritance to be useful, properties with
+    # the same name on different mark types should have equivalent meaning.)
+    #
+    # <p>This method differs slightly from the normal mark behavior in that the
+    # anchor's target is preserved.
+    #
+    # @param {Rubyvis::Mark} proto the new prototype.
+    # @returns {Rubyvis::Anchor} this anchor.
+    # @see Rubyvis.Mark#add
+    
+    def mark_extend(proto)
+      @proto=proto
+      self
+    end
+  end
+end
diff --git a/lib/rubyvis/mark/area.rb b/lib/rubyvis/mark/area.rb
new file mode 100644
index 0000000..d719436
--- /dev/null
+++ b/lib/rubyvis/mark/area.rb
@@ -0,0 +1,227 @@
+module Rubyvis
+  # Alias for Rubyvis::Area
+  def self.Area
+    Rubyvis::Area
+  end
+  # Provides methods pertinents to area like-marks.
+  module AreaPrototype  # :nodoc:
+    def fixed
+      {
+        :line_width=> true,
+        :line_join=> true,
+        :stroke_style=> true,
+        :fill_style=> true,
+        :segmented=> true,
+        :interpolate=> true,
+        :tension=> true
+      }
+    end
+    def area_build_instance(s)
+      binds = self.binds
+      # Handle fixed properties on secondary instances. */
+      if (self.index!=0)
+        fixed = @binds.fixed
+        #/* Determine which properties are fixed. */
+        if (!fixed)
+          binds.fixed=[]
+          fixed = binds.fixed
+          filter=lambda {|prop|
+            if prop.fixed
+              fixed.push(prop)
+              false
+            else
+              true
+            end
+          }
+          #      p binds.required
+          binds.required = binds.required.find_all(&filter)
+          #      p binds.required
+          if (!self.scene[0].segmented)
+            binds.optional = binds.optional.find_all(&filter)
+          end
+          
+        end
+        
+        #    p binds.required
+
+
+        #/* Copy fixed property values from the first instance. */
+        fixed.each {|prop|
+          name=prop.name
+          s[name]=self.scene[0][name]
+        }
+        
+        
+        #    p binds.fixed
+        #/* Evaluate all properties on the first instance. */
+      else
+        binds.required = binds._required
+        binds.optional = binds._optional
+        binds.fixed = nil
+      end
+      # pp binds
+      mark_build_instance(s)
+    end
+
+
+
+    def area_bind
+      mark_bind
+      
+      binds = self.binds
+      required = binds.required
+      optional = binds.optional
+      
+      optional.size.times {|i|
+        prop = optional[i]
+        prop.fixed = fixed.keys.include? prop.name
+        
+        if (prop.name == "segmented")
+          required.push(prop)
+        end
+      }
+      optional.delete_if {|v| v.name=='segmented'}
+      # Cache the original arrays so they can be restored on build. */
+      @binds._required = required
+      @binds._optional = optional
+    end
+
+
+    def area_anchor(name)
+      #scene=nil
+      anchor=mark_anchor(name)
+      anchor.interpolate(lambda {
+        self.scene.target[self.index].interpolate
+      }).eccentricity(lambda {
+        self.scene.target[self.index].eccentricity
+      }).tension(lambda {
+        self.scene.target[self.index].tension
+      })
+      anchor
+    end
+  end
+  
+  # Represents an area mark: the solid area between two series of
+  # connected line segments. Unsurprisingly, areas are used most frequently for
+  # area charts.
+  #
+  # <p>Just as a line represents a polyline, the <tt>Area</tt> mark type
+  # represents a <i>polygon</i>. However, an area is not an arbitrary polygon;
+  # vertices are paired either horizontally or vertically into parallel
+  # <i>spans</i>, and each span corresponds to an associated datum. Either the
+  # width or the height must be specified, but not both; this determines whether
+  # the area is horizontally-oriented or vertically-oriented.  Like lines, areas
+  # can be stroked and filled with arbitrary colors.
+
+  class Area < Mark
+    include AreaPrototype
+    @properties=Mark.properties.dup
+    
+    
+  ##
+  # :attr: width
+  # The width of a given span, in pixels; used for horizontal spans. If the width
+  # is specified, the height property should be 0 (the default). Either the top
+  # or bottom property should be used to space the spans vertically, typically as
+  # a multiple of the index.
+  
+  
+  ##
+  # :attr: height  
+  # The height of a given span, in pixels; used for vertical spans. If the height
+  # is specified, the width property should be 0 (the default). Either the left
+  # or right property should be used to space the spans horizontally, typically
+  # as a multiple of the index.
+  
+  
+  ##
+  # :attr: line_width  
+  # The width of stroked lines, in pixels; used in conjunction with
+  # <tt>strokeStyle</tt> to stroke the perimeter of the area. Unlike the
+  # {@link Line} mark type, the entire perimeter is stroked, rather than just one
+  # edge. The default value of this property is 1.5, but since the default stroke
+  # style is null, area marks are not stroked by default.
+  #
+  # <p>This property is <i>fixed</i> for non-segmented areas. See
+  # {@link pv.Mark}.
+  
+  
+  ##
+  # :attr: stroke_style
+  # The style of stroked lines; used in conjunction with <tt>lineWidth</tt> to
+  # stroke the perimeter of the area. Unlike the {@link Line} mark type, the
+  # entire perimeter is stroked, rather than just one edge. The default value of
+  # this property is null, meaning areas are not stroked by default.
+  #
+  # <p>This property is <i>fixed</i> for non-segmented areas. See
+  # {@link pv.Mark}.
+  #
+  
+  
+  ##
+  # :attr: fill_style  
+  # The area fill style; if non-null, the interior of the polygon forming the
+  # area is filled with the specified color. The default value of this property
+  # is a categorical color.
+  #
+  # <p>This property is <i>fixed</i> for non-segmented areas. See
+  # {@link pv.Mark}.
+  
+  
+  ##
+  # :attr: segmented  
+  # Whether the area is segmented; whether variations in fill style, stroke
+  # style, and the other properties are treated as fixed. Rendering segmented
+  # areas is noticeably slower than non-segmented areas.
+  #
+  # <p>This property is <i>fixed</i>. See {@link pv.Mark}.
+  
+  
+  ##
+  # :attr: interpolate  
+  # How to interpolate between values. Linear interpolation ("linear") is the
+  # default, producing a straight line between points. For piecewise constant
+  # functions (i.e., step functions), either "step-before" or "step-after" can
+  # be specified. To draw open uniform b-splines, specify "basis".
+  # To draw cardinal splines, specify "cardinal"; see also Line.tension()
+  #
+  # <p>This property is <i>fixed</i>. See {@link pv.Mark}.
+  
+  
+  ##
+  # :attr: tension  
+  # The tension of cardinal splines; used in conjunction with
+  # interpolate("cardinal"). A value between 0 and 1 draws cardinal splines with
+  # the given tension. In some sense, the tension can be interpreted as the
+  # "length" of the tangent; a tension of 1 will yield all zero tangents (i.e.,
+  # linear interpolation), and a tension of 0 yields a Catmull-Rom spline. The
+  # default value is 0.7.
+  #
+  # <p>This property is <i>fixed</i>. See {@link pv.Mark}.
+    
+    
+    
+    attr_accessor_dsl :width, :height, :line_width, [:stroke_style, lambda {|d| Rubyvis.color(d)}], [:fill_style, lambda {|d| Rubyvis.color(d)}], :segmented, :interpolate, :tension
+    def type
+      'area'
+    end
+    def bind
+      area_bind
+    end
+    def build_instance(s)
+      area_build_instance(s)
+    end
+    def self.defaults
+      a= Rubyvis::Colors.category20
+      Area.new.mark_extend(Mark.defaults).line_width(1.5).fill_style(lambda {a.scale(self.parent.index)}).interpolate('linear').tension(0.7)
+    end
+    def anchor(name)
+      area_anchor(name)
+    end
+    def build_implied(s)
+      s.height=0 if s.height.nil?
+      s.width=0 if s.width.nil?
+      mark_build_implied(s)
+    end
+  end
+end
diff --git a/lib/rubyvis/mark/bar.rb b/lib/rubyvis/mark/bar.rb
new file mode 100644
index 0000000..c3a11da
--- /dev/null
+++ b/lib/rubyvis/mark/bar.rb
@@ -0,0 +1,69 @@
+module Rubyvis
+  # Alias for Rubyvis::Bar
+  def self.Bar
+    Rubyvis::Bar
+  end
+  
+  # Represents a bar: an axis-aligned rectangle that can be stroked and
+  # filled. Bars are used for many chart types, including bar charts, histograms
+  # and Gantt charts. Bars can also be used as decorations, for example to draw a
+  # frame border around a panel; in fact, a panel is a special type (a subclass)
+  # of bar.
+  #
+  # Bars can be positioned in several ways. Most commonly, one of the four
+  # corners is fixed using two margins, and then the width and height properties
+  # determine the extent of the bar relative to this fixed location. For example,
+  # using the bottom and left properties fixes the bottom-left corner; the width
+  # then extends to the right, while the height extends to the top. As an
+  # alternative to the four corners, a bar can be positioned exclusively using
+  # margins; this is convenient as an inset from the containing panel, for
+  # example. See Mark for details on the prioritization of redundant
+  # positioning properties.
+  class Bar < Mark
+    
+    def type # :nodoc:
+      "bar"
+    end
+
+    @properties=Mark.properties.dup
+    
+    
+    ##
+    # :attr: width
+    # The width of the bar, in pixels. If the left position is specified, the bar
+    # extends rightward from the left edge; if the right position is specified, the
+    # bar extends leftward from the right edge.
+    
+    ##
+    # :attr: height
+    # The height of the bar, in pixels. If the bottom position is specified, the
+    # bar extends upward from the bottom edge; if the top position is specified,
+    # the bar extends downward from the top edge.
+    
+    ##
+    # :attr: line_width    
+    # The width of stroked lines, in pixels; used in conjunction with
+    # stroke_style to stroke the bar's border.
+    
+    ##
+    # :attr: stroke_style
+    # The style of stroked lines; used in conjunction with line_width to
+    # stroke the bar's border. The default value of this property is nil, meaning bars are not stroked by default.
+    
+    ##
+    # :attr: fill_style
+    # The bar fill style; if non-nil, the interior of the bar is filled with the
+    # specified color. The default value of this property is a categorical color.
+    
+    attr_accessor_dsl :width, :height, :line_width, [:stroke_style, lambda {|d| Rubyvis.color(d)}], [:fill_style, lambda {|d| Rubyvis.color(d)}]
+    
+    # Default properties for bars. By default, there is no stroke and the fill
+    # style is a categorical color.
+    def self.defaults
+      a=Rubyvis.Colors.category20()
+      Bar.new.mark_extend(Mark.defaults).line_width(1.5).fill_style( lambda {
+          a.scale(self.parent.index)
+      })
+    end
+  end
+end
diff --git a/lib/rubyvis/mark/dot.rb b/lib/rubyvis/mark/dot.rb
new file mode 100644
index 0000000..9dc8f23
--- /dev/null
+++ b/lib/rubyvis/mark/dot.rb
@@ -0,0 +1,168 @@
+module Rubyvis
+  # Alias por Rubyvis::Dot
+  def self.Dot
+    Rubyvis::Dot
+  end
+  # Represents a dot; a dot is simply a sized glyph centered at a given
+  # point that can also be stroked and filled. The <tt>size</tt> property is
+  # proportional to the area of the rendered glyph to encourage meaningful visual
+  # encodings. Dots can visually encode up to eight dimensions of data, though
+  # this may be unwise due to integrality. See Mark for details on the
+  # prioritization of redundant positioning properties.  
+  class Dot < Mark
+    # Type of mark
+    def type
+      "dot"
+    end
+
+    @properties=Mark.properties.dup
+    
+    ##
+    # :attr: shape_size
+    # The size of the shape, in square pixels. Square pixels are used such that the
+    # area of the shape is linearly proportional to the value of the
+    # <tt>shape_size</tt> property, facilitating representative encodings. This is
+    # an alternative to using shape_radius
+    #
+    
+    ##
+    # :attr: shape_radius 
+    # The radius of the shape, in pixels. This is an alternative to using
+    # shape_size
+    #
+    
+    ##
+    # :attr: shape
+    # The shape name. Several shapes are supported:<ul>
+    #
+    # <li>cross
+    # <li>triangle
+    # <li>diamond
+    # <li>square
+    # <li>circle
+    # <li>tick
+    # <li>bar
+    #
+    # </ul>These shapes can be further changed using the angle() property;
+    # for instance, a cross can be turned into a plus by rotating. Similarly, the
+    # tick, which is vertical by default, can be rotated horizontally. Note that
+    # some shapes (cross and tick) do not have interior areas, and thus do not
+    # support fill style meaningfully.
+    #
+    # <p>Note: it may be more natural to use the Rule mark for
+    # horizontal and vertical ticks. The tick shape is only necessary if angled
+    # ticks are needed.
+    
+    ##
+    # :attr: shape_angle
+    # The shape rotation angle, in radians. Used to rotate shapes, such as to turn
+    # a cross into a plus.
+    
+    ##
+    # :attr: line_width
+    # The width of stroked lines, in pixels; used in conjunction with
+    # +stroke_style+ to stroke the dot's shape.
+    
+    ##
+    # :attr: stroke_style
+    # The style of stroked lines; used in conjunction with +line_width+ to
+    # stroke the dot's shape. The default value of this property is a categorical color. See Rubyvis.color()
+    
+    ##
+    # :attr: fill_style
+    # The fill style; if non-nil, the interior of the dot is filled with the
+    # specified color. The default value of this property is nil, meaning dots are
+    # not filled by default. See Rubyvis.color()
+    
+    attr_accessor_dsl :shape, :shape_angle, :shape_radius, :shape_size, :line_width, [:stroke_style, lambda {|d| Rubyvis.color(d)}], [:fill_style, lambda {|d| Rubyvis.color(d)}]
+    # Default properties for dots. By default, there is no fill and the stroke
+    # style is a categorical color. The default shape is "circle" with radius 4.5.
+    def self.defaults()
+      a=Rubyvis::Colors.category10
+      Dot.new().mark_extend(Mark.defaults).shape("circle"). line_width(1.5). stroke_style(lambda {a.scale(self.parent.index)})
+    end
+    # Constructs a new dot anchor with default properties. Dots support five
+    # different anchors:<ul>
+    #
+    # <li>top
+    # <li>left
+    # <li>center
+    # <li>bottom
+    # <li>right
+    #
+    # </ul>In addition to positioning properties (left, right, top bottom), the
+    # anchors support text rendering properties (text-align, text-baseline). Text is
+    # rendered to appear outside the dot. Note that this behavior is different from
+    # other mark anchors, which default to rendering text <i>inside</i> the mark.
+    #
+    # <p>For consistency with the other mark types, the anchor positions are
+    # defined in terms of their opposite edge. For example, the top anchor defines
+    # the bottom property, such that a bar added to the top anchor grows upward.
+    def anchor(name)
+      mark_anchor(name).left(lambda {
+        s=scene.target[self.index]
+        case self.name
+          when 'bottom' then s.left;
+          when 'top' then s.left;
+          when 'center' then s.left;
+          when 'left' then nil;
+          else
+            s.left+s.shape_radius
+        end
+      }).right(lambda {
+        s=scene.target[self.index]
+        self.name()=='left' ? s.right+s.shape_radius : nil
+      }).top(lambda {
+        s=scene.target[self.index]
+        case self.name
+          when 'left' then  s.top;
+          when 'right' then s.top;
+          when 'center' then s.top;
+          when 'top' then nil;
+          else
+            s.top+s.shape_radius
+        end
+      }).bottom(lambda {
+        s=scene.target[self.index]
+        self.name()=='top' ? s.bottom+s.shape_radius : nil
+      }).text_align(lambda {
+        case self.name
+          when 'left' then  'right';
+          when 'bottom' then 'center';
+          when 'top' then 'center';
+          when 'center' then 'center';
+          else
+            'left'
+        end
+      }).text_baseline( lambda {
+        case self.name
+          when 'right' then  'middle';
+          when 'left' then 'middle';
+          when 'center' then 'middle';
+          when 'bottom' then 'top';
+          else
+            'bottom'
+        end
+      
+      })
+    end
+    
+    
+    # @private Sets radius based on size or vice versa. 
+    def build_implied(s) # :nodoc:
+      r = s.shape_radius
+      z = s.shape_size
+      if (r.nil?) 
+        if (z.nil?) 
+          s.shape_size = 20.25;
+          s.shape_radius = 4.5;
+        else
+          s.shape_radius = Math.sqrt(z)
+        end
+      elsif (z.nil?) 
+        s.shape_size = r * r;
+      end
+      mark_build_implied(s)
+    end
+  end
+end
diff --git a/lib/rubyvis/mark/image.rb b/lib/rubyvis/mark/image.rb
new file mode 100644
index 0000000..7166afc
--- /dev/null
+++ b/lib/rubyvis/mark/image.rb
@@ -0,0 +1,96 @@
+module Rubyvis
+  def self.Image
+    Rubyvis::Image
+  end
+  class Image < Bar
+    def type
+      "image"
+    end
+    @properties=Bar.properties.dup
+    attr_accessor :_image
+    def initialize(opts=Hash.new)
+      super(opts)
+      @_image=nil
+    end
+    ##
+    # :attr: url
+    # The URL of the image to display. The set of supported image types is
+    # browser-dependent; PNG and JPEG are recommended.
+    
+    ##
+    # :attr: image_width
+    # The width of the image in pixels. For static images, this property is
+    # computed implicitly from the loaded image resources. For dynamic images, this
+    # property can be used to specify the width of the pixel buffer; otherwise, the
+    # value is derived from the <tt>width</tt> property.
+    
+    ##
+    # :attr: image_height
+    # The height of the image in pixels. For static images, this property is
+    # computed implicitly from the loaded image resources. For dynamic images, this
+    # property can be used to specify the height of the pixel buffer; otherwise, the
+    # value is derived from the <tt>height</tt> property.
+    
+    attr_accessor_dsl :url, :image_width, :image_height
+    
+    
+    # Default properties for images. By default, there is no stroke or fill style.
+    def self.defaults
+      Image.new.mark_extend(Bar.defaults).fill_style(nil)
+    end
+    
+    # @TODO: NOT IMPLEMENTED YET
+    # Specifies the dynamic image function. By default, no image function is
+    # specified and the <tt>url</tt> property is used to load a static image
+    # resource. If an image function is specified, it will be invoked for each
+    # pixel in the image, based on the related <tt>imageWidth</tt> and
+    # <tt>imageHeight</tt> properties.
+    #
+    # <p>For example, given a two-dimensional array <tt>heatmap</tt>, containing
+    # numbers in the range [0, 1] in row-major order, a simple monochrome heatmap
+    # image can be specified as:
+    #
+    #   vis.add(pv.Image)
+    #     .image_width(heatmap[0].length)
+    #     .image_height(heatmap.length)
+    #     .image(pv.ramp("white", "black").by(lambda {|x,y| heatmap[y][x]}))
+    #
+    # For fastest performance, use an ordinal scale which caches the fixed color
+    # palette, or return an object literal with <tt>r</tt>, <tt>g</tt>, <tt>b</tt>
+    # and <tt>a</tt> attributes. A {@link pv.Color} or string can also be returned,
+    # though this typically results in slower performance.
+    
+    def dynamic_image(f)
+      #f,dummy=arguments
+      @_image = lambda {|*args|
+        c=f.js_apply(self,args)
+        c.nil? ? pv.Color.transparent : (c.is_a?(String) ? Rubyvis.color(c) : c )
+      }
+      self
+    end
+    
+    
+    # Scan the proto chain for an image function.
+    def bind
+      mark_bind
+      bind=self.binds
+      mark=self
+      begin
+        binds.image = mark._image
+      end while(!binds.image and (mark==mark.proto))
+    end
+    
+    
+    def build_implied(s)
+      mark_build_implied(s)
+      return if !s.visible
+      # Compute the implied image dimensions. */
+      s.image_width = s.width   if s.image_width.nil?
+      s.image_height = s.height if s.image_height.nil?
+      # Compute the pixel values. */
+      if (s.url.nil? and self.binds.image)
+        raise "not implemented yet"
+      end
+    end
+  end
+end
diff --git a/lib/rubyvis/mark/label.rb b/lib/rubyvis/mark/label.rb
new file mode 100644
index 0000000..f5ed1f2
--- /dev/null
+++ b/lib/rubyvis/mark/label.rb
@@ -0,0 +1,107 @@
+module Rubyvis
+  # Alias for Rubyvis::Label
+  def self.Label
+    Rubyvis::Label
+  end
+  # Represents a text label, allowing textual annotation of other marks or
+  # arbitrary text within the visualization. The character data must be plain
+  # text (unicode), though the text can be styled using the {@link #font}
+  # property. If rich text is needed, external HTML elements can be overlaid on
+  # the canvas by hand.
+  #
+  # <p>Labels are positioned using the box model, similarly to {@link Dot}. Thus,
+  # a label has no width or height, but merely a text anchor location. The text
+  # is positioned relative to this anchor location based on the
+  # text_align, text_baseline and text_margin properties.
+  # Furthermore, the text may be rotated using text_angle
+  class Label < Mark
+    @properties=Mark.properties.dup
+    
+    ##
+    # :attr: text
+    # The character data to render; a string. The default value of the text
+    # property is the identity function, meaning the label's associated datum will
+    # be rendered using its to_s()
+    
+    ##
+    # :attr: font
+    # The font format, per the CSS Level 2 specification. The default font is "10px
+    # sans-serif", for consistency with the HTML 5 canvas element specification.
+    # Note that since text is not wrapped, any line-height property will be
+    # ignored. The other font-style, font-variant, font-weight, font-size and
+    # font-family properties are supported.
+    #
+    # @see {CSS2 fonts}[http://www.w3.org/TR/CSS2/fonts.html#font-shorthand]
+    
+    ##
+    # :attr: text_angle
+    # The rotation angle, in radians. Text is rotated clockwise relative to the
+    # anchor location. For example, with the default left alignment, an angle of
+    # Math.PI / 2 causes text to proceed downwards. The default angle is zero.
+    
+    ##
+    # :attr: text_style
+    # The text color. The name "text_style" is used for consistency with "fill_style"
+    # and "stroke_style", although it might be better to rename this property (and
+    # perhaps use the same name as "stroke_style"). The default color is black.
+    # See Rubyvis.color()
+    
+    ##
+    # :attr: text_align
+    # The horizontal text alignment. One of:<ul>
+    #
+    # <li>left
+    # <li>center
+    # <li>right
+    #
+    # </ul>The default horizontal alignment is left.
+    
+    
+    ##
+    # :attr: text_baseline
+    # The vertical text alignment. One of:<ul>
+    #
+    # <li>top
+    # <li>middle
+    # <li>bottom
+    #
+    # </ul>The default vertical alignment is bottom.
+    
+    
+    ##
+    # :attr: text_margin
+    # The text margin; may be specified in pixels, or in font-dependent units (such
+    # as ".1ex"). The margin can be used to pad text away from its anchor location,
+    # in a direction dependent on the horizontal and vertical alignment
+    # properties. For example, if the text is left- and middle-aligned, the margin
+    # shifts the text to the right. The default margin is 3 pixels.
+    
+    
+    ##
+    # :attr: text_shadow
+    # A list of shadow effects to be applied to text, per the CSS Text Level 3
+    # text-shadow property. An example specification is "0.1em 0.1em 0.1em
+    # rgba(0,0,0,.5)"; the first length is the horizontal offset, the second the
+    # vertical offset, and the third the blur radius.
+    #
+    # See {CSS3 text}[http://www.w3.org/TR/css3-text/#text-shadow]
+    
+    ##
+    # :attr: text_decoration
+    # A list of decoration to be applied to text, per the CSS Text Level 3
+    # text-decoration property. An example specification is "underline".
+    #
+    # See {CSS3 text}[http://www.w3.org/TR/css3-text/#text-decoration]
+    
+    
+    attr_accessor_dsl :text, :font, :text_angle, [:text_style, lambda {|d| Rubyvis.color(d)}], :text_align, :text_baseline, :text_margin, :text_decoration, :text_shadow
+    # Mark type
+    def type
+      'label'
+    end
+    # Default properties for labels. See the individual properties for the default values.
+    def self.defaults
+      Label.new.mark_extend(Mark.defaults).events('none').text(Rubyvis.identity).font("10px sans-serif" ).text_angle( 0 ).text_style( 'black' ).text_align( 'left' ).text_baseline( 'bottom' ).text_margin(3)
+    end
+  end
+end
diff --git a/lib/rubyvis/mark/line.rb b/lib/rubyvis/mark/line.rb
new file mode 100644
index 0000000..aca97d0
--- /dev/null
+++ b/lib/rubyvis/mark/line.rb
@@ -0,0 +1,152 @@
+module Rubyvis
+  # Alias for Rubyvis::Line
+  def self.Line
+    Rubyvis::Line
+  end
+  # Provides methods pertinents to line like marks.  
+  module LinePrototype  # :nodoc:
+    include AreaPrototype
+    def line_anchor(name)
+      
+      anchor=area_anchor(name).text_align(lambda {|d|
+          {'left'=>'right', 'bottom'=>'center', 'top'=>'center', 'center'=>'center','right'=>'left'}[self.name()]
+      }).text_baseline(lambda{|d|
+        {'top'=>'bottom', 'right'=>'middle', 'left'=>'middle','center'=>'middle', 'bottom'=>'top'}[self.name()]
+      })
+      anchor
+    end
+  end
+  
+  # Represents a series of connected line segments, or <i>polyline</i>,
+  # that can be stroked with a configurable color and thickness. Each
+  # articulation point in the line corresponds to a datum; for <i>n</i> points,
+  # <i>n</i>-1 connected line segments are drawn. The point is positioned using
+  # the box model. Arbitrary paths are also possible, allowing radar plots and
+  # other custom visualizations.
+  #
+  # <p>Like areas, lines can be stroked and filled with arbitrary colors. In most
+  # cases, lines are only stroked, but the fill style can be used to construct
+  # arbitrary polygons.
+  class Line < Mark
+    include AreaPrototype
+    include LinePrototype
+    @properties=Mark.properties.dup
+    
+      
+    ##
+    # :attr: line_width
+    # The width of stroked lines, in pixels; used in conjunction with
+    # +stroke_style+ to stroke the line.
+    
+    
+    ##
+    # :attr: stroke_style
+    # The style of stroked lines; used in conjunction with <tt>lineWidth</tt> to
+    # stroke the line. The default value of this property is a categorical color.
+    
+    
+    ##
+    # :attr: line_join
+    # The type of corners where two lines meet. Accepted values are "bevel",
+    # "round" and "miter". The default value is "miter".
+    #
+    # <p>For segmented lines, only "miter" joins and "linear" interpolation are
+    # currently supported. Any other value, including nil, will disable joins,
+    # producing disjoint line segments. Note that the miter joins must be computed
+    # manually (at least in the current SVG renderer); since this calculation may
+    # be expensive and unnecessary for small lines, specifying nil can improve
+    # performance significantly.
+    #
+    # <p>This property is <i>fixed</i>. See Rubyvis.Mark    
+    
+    ##
+    # :attr: fill_style
+    # The line fill style; if non-nil, the interior of the line is closed and
+    # filled with the specified color. The default value of this property is a
+    # nil, meaning that lines are not filled by default.
+    #
+    # <p>This property is <i>fixed</i>. See Rubyvis.Mark    
+    
+    
+    ##
+    # :attr: segmented
+    # Whether the line is segmented; whether variations in stroke style, line width and the other properties are treated as fixed. Rendering segmented lines is noticeably slower than non-segmented lines.
+    # <p>This property is <i>fixed</i>. See Rubyvis.Mark    
+    
+    
+    ##
+    # :attr: interpolate
+    # How to interpolate between values. Linear interpolation ("linear") is the
+    # default, producing a straight line between points. For piecewise constant
+    # functions (i.e., step functions), either "step-before" or "step-after" 
+    # can be specified. To draw a clockwise circular arc between points, 
+    # specify "polar"; to draw a counterclockwise circular arc between points,
+    # specify "polar-reverse". To draw open uniform b-splines, specify "basis". # To draw cardinal splines, specify "cardinal"; see also Line.tension()
+    #
+    # <p>This property is <i>fixed</i>. See Rubyvis.Mark    
+    
+    
+    ## 
+    # :attr: eccentricity
+    # The eccentricity of polar line segments; used in conjunction with
+    # interpolate("polar"). The default value of 0 means that line segments are
+    # drawn as circular arcs. A value of 1 draws a straight line. A value between 0
+    # and 1 draws an elliptical arc with the given eccentricity.
+    
+    
+    ##
+    # :attr: tension
+    # The tension of cardinal splines; used in conjunction with
+    # interpolate("cardinal"). A value between 0 and 1 draws cardinal splines with
+    # the given tension. In some sense, the tension can be interpreted as the
+    # "length" of the tangent; a tension of 1 will yield all zero tangents (i.e.,
+    # linear interpolation), and a tension of 0 yields a Catmull-Rom spline. The
+    # default value is 0.7.
+    #
+    # <p>This property is <i>fixed</i>. See Rubyvis.Mark    
+    
+    attr_accessor_dsl :line_width, :line_join, [:stroke_style, lambda {|d| Rubyvis.color(d)}], [:fill_style, lambda {|d| Rubyvis.color(d)}], :segmented, :interpolate, :eccentricity, :tension
+    # Type of line
+    def type
+      "line"
+    end
+    
+    # Constructs a new line anchor with default properties. Lines support five
+    # different anchors:<ul>
+    #
+    # <li>top
+    # <li>left
+    # <li>center
+    # <li>bottom
+    # <li>right
+    #
+    # </ul>In addition to positioning properties (left, right, top bottom), the
+    # anchors support text rendering properties (text-align, text-baseline). Text is
+    # rendered to appear outside the line. Note that this behavior is different
+    # from other mark anchors, which default to rendering text <i>inside</i> the
+    # mark.
+    #
+    # <p>For consistency with the other mark types, the anchor positions are
+    # defined in terms of their opposite edge. For example, the top anchor defines
+    # the bottom property, such that a bar added to the top anchor grows upward.
+    def anchor(name)
+      line_anchor(name)
+    end
+    # Reuse Area's implementation for segmented bind & build.
+    def bind(*args) # :nodoc:
+      area_bind(*args)
+    end
+    # Reuse Area's implementation for segmented bind & build.
+    
+    def build_instance(*args) # :nodoc:
+      area_build_instance(*args)
+    end
+    # Default properties for lines. By default, there is no fill and the stroke
+    # style is a categorical color. The default interpolation is linear.
+
+    def self.defaults
+      a=Rubyvis::Colors.category10()
+      Line.new.mark_extend(Mark.defaults).line_join('miter').line_width(1.5).stroke_style( lambda { a.scale(parent.index)}).interpolate('linear').eccentricity(0).tension(0.7)
+    end
+  end
+end
diff --git a/lib/rubyvis/mark/panel.rb b/lib/rubyvis/mark/panel.rb
new file mode 100644
index 0000000..220b465
--- /dev/null
+++ b/lib/rubyvis/mark/panel.rb
@@ -0,0 +1,138 @@
+module Rubyvis
+  # Alias for Rubyvis::Panel
+  def self.Panel
+    Rubyvis::Panel
+  end
+  class Panel < Bar
+    def type
+      "panel"
+    end
+
+    @properties=Bar.properties.dup
+    attr_accessor_dsl :transform, :overflow, :canvas
+    attr_accessor :children, :root
+    def initialize
+      @children=[]
+      @root=self
+      super
+      
+    end
+    def children_inspect(level=0)
+      out=[]
+      @children.each do |c|
+        out << ("  "*level)+"- #{c.type} (#{c.object_id}) proto:#{c.proto.object_id} target:#{c.target.object_id}"
+        if c.respond_to? :children and c.children
+          out << c.children_inspect(level+1)
+        end
+      end
+      out
+
+    end
+
+    def self.defaults
+      Panel.new.mark_extend(Bar.defaults).fill_style(nil).overflow('visible')
+    end
+    def add(type)
+      child=type.new
+      child.parent=self
+      child.root=root
+      child.child_index=children.size
+      children.push(child)
+      child
+    end
+
+    attr_reader :_canvas
+    def bind
+      super
+      children.each {|c|
+        c.bind()
+      }
+    end
+    def anchor(name)
+      anchor=mark_anchor(name)
+      anchor.parent=self
+      anchor
+    end
+    def build_instance(s)
+      super(s)
+      return if !s.visible
+      s.children=[] if !s.children
+      scale=self.scale * s.transform.k
+      n=self.children.size
+      Mark.index=-1
+      n.times {|i|
+        child=children[i]
+        child.scene=s.children[i]
+        child.scale=scale
+        child.build
+      }
+      n.times {|i|
+        child=children[i]
+        s.children[i]=child.scene
+        child.scene=nil
+        child.scale=nil
+      }
+      s.children=s.children[0,n]
+
+    end
+
+    def to_svg
+      if Rubyvis.xml_engine==:nokogiri
+        @_canvas.sort.map {|v|
+          v[1].get_element(1).to_xml(:indent => 5, :encoding => 'UTF-8')
+        }.join
+      else
+        @_canvas.sort.map {|v|
+          bar = REXML::Formatters::Default.new
+          out = String.new
+          bar.write(v[1].elements[1], out)
+        }.join
+      end
+    end
+    def build_implied(s)
+      panel_build_implied(s)
+    end
+    def panel_build_implied(s)
+      if(!self.parent)
+        c=s.canvas
+        if(c)
+          if(c._panel!=self)
+            c._panel=self
+            c.delete_if? {true}
+          end
+          if s.width.nil?
+            w=Rubyvis.css(c,'width')
+            s.width=w - s.left - s.right
+          end
+          if s.height.nil?
+            w=Rubyvis.css(c,'height')
+            s.height=h - s.top - s.bottom
+          end
+
+        else
+          @_canvas||={}
+          cache=@_canvas
+          if(!(c=cache[self.index]))
+          
+          if Rubyvis.xml_engine==:nokogiri
+            document=Nokogiri::XML::Document.new
+            document.root=document.create_element('document')
+            Rubyvis.nokogiri_document(document)
+          else
+            document=REXML::Document.new
+            document.add_element("document")            
+          end
+            cache[self.index]=document.root
+            c=cache[self.index]
+            
+            #c=cache[self.index]=Rubyvis.document.add_element('span')
+          end
+        end
+        s.canvas=c
+      end
+      s.transform=Rubyvis.Transform.identity if (s.transform.nil?)
+      mark_build_implied(s)
+    end
+
+  end
+end
diff --git a/lib/rubyvis/mark/rule.rb b/lib/rubyvis/mark/rule.rb
new file mode 100644
index 0000000..d55478d
--- /dev/null
+++ b/lib/rubyvis/mark/rule.rb
@@ -0,0 +1,35 @@
+module Rubyvis
+  # Alias for Rubyvis::Rule
+  def self.Rule
+    Rubyvis::Rule
+  end
+  class Rule < Mark
+    include LinePrototype
+    @properties=Mark.properties.dup
+    attr_accessor_dsl :width, :height, :line_width, [:stroke_style, lambda {|d| Rubyvis.color(d)}]
+    def self.defaults
+      Rule.new.mark_extend(Mark.defaults).line_width(1).stroke_style('black').antialias(false)
+    end
+    
+    def type
+      'rule'
+    end
+
+    def anchor(name)
+      line_anchor(name)
+    end
+    def build_implied(s)
+      l=s.left
+      r=s.right
+      #t=s.top
+      #b=s.bottom
+      
+      if((!s.width.nil?) or ((l.nil?) and (r.nil?)) or ((!r.nil?) and (!l.nil?)))
+        s.height=0
+      else
+        s.width=0
+      end
+      mark_build_implied(s)
+    end
+  end
+end
diff --git a/lib/rubyvis/mark/shorcut_methods.rb b/lib/rubyvis/mark/shorcut_methods.rb
new file mode 100644
index 0000000..0a07f43
--- /dev/null
+++ b/lib/rubyvis/mark/shorcut_methods.rb
@@ -0,0 +1,314 @@
+class Rubyvis::Mark
+  ##
+  # :section: RBP Api
+  ##
+  
+  # Create a new Mark method shorcut.
+  def self.mark_method(name, mark) #:nodoc:
+    define_method(name) do |*args,&block|
+      opts=args[0]
+      opts||=Hash.new
+      if opts[:anchor]
+        base=anchor(opts[:anchor])
+      else
+        base=self
+      end
+      a=base.add(mark)
+      if block
+        block.arity<1 ? a.instance_eval(&block) : block.call(a)
+      end
+      a
+    end
+  end
+  ##
+  # :method: area(opts, &block)
+  #
+  # Adds an Area mark to current mark. 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use
+  
+  mark_method :area, Rubyvis::Area
+  ##
+  # :method: bar(opts,&block)
+  #
+  # Adds a Bar mark to current mark. 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use
+  
+  mark_method :bar, Rubyvis::Bar
+  ##
+  # :method: dot(opts,&block)
+  #
+  # Adds a Dot mark to current mark. 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use  
+
+  mark_method :dot, Rubyvis::Dot
+  ##
+  # :method: image(opts,&block)
+  #
+  # Adds an Image mark to current mark. 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+  #
+  mark_method :image, Rubyvis::Image
+  
+  ##
+  # :method: label(opts,&block)
+  #
+  # Adds a Label mark to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use  
+  
+  mark_method :label, Rubyvis::Label
+  ##
+  # :method: line(opts,&block)
+  #
+  # Adds a Line mark to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+  #
+  mark_method :line, Rubyvis::Line
+  ##
+  # :method: panel(opts,&block)
+  #
+  # Adds a Panel mark to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+  #
+  mark_method :panel, Rubyvis::Panel
+  ##  
+  # :method: rule(opts,&block)
+  #
+  # Adds a Rule mark to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+
+  mark_method :rule, Rubyvis::Rule
+  ##
+  # :method: wedge(opts,&block)  
+  #
+  # Adds a Wedge mark to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+
+  mark_method :wedge, Rubyvis::Wedge
+  ##
+  # :method: layout_stack(opts,&block)  
+  #
+  # Adds a Layout::Stack to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+  mark_method :layout_stack, Rubyvis::Layout::Stack
+  
+  ##
+  # :method: layout_partition(opts,&block)  
+  #
+  # Adds a Layout::Partition to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+  mark_method :layout_partition, Rubyvis::Layout::Partition
+  
+  ##
+  # :method: layout_partition_fill(opts,&block)  
+  #
+  # Adds a Layout::Partition::Fill to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+  mark_method :layout_partition_fill, Rubyvis::Layout::Partition::Fill
+  
+  ##
+  # :method: layout_treemap(opts,&block)  
+  #
+  # Adds a Layout::Treemap to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+  mark_method :layout_treemap, Rubyvis::Layout::Treemap
+  
+  ##
+  # :method: layout_cluster(opts,&block)  
+  #
+  # Adds a Layout::Cluster to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+  mark_method :layout_cluster, Rubyvis::Layout::Cluster
+  
+  ##
+  # :method: layout_indent(opts,&block)  
+  #
+  # Adds a Layout::Indent to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+  mark_method :layout_indent, Rubyvis::Layout::Indent
+
+  ##
+  # :method: layout_pack(opts,&block)  
+  #
+  # Adds a Layout::Pack to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+  mark_method :layout_pack, Rubyvis::Layout::Pack
+
+  ##
+  # :method: layout_grid(opts,&block)
+  #
+  # Adds a Layout::Grid to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+  mark_method :layout_grid, Rubyvis::Layout::Grid
+
+  ##
+  # :method: layout_tree(opts,&block)
+  #
+  # Adds a Layout::Tree to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+  mark_method :layout_tree, Rubyvis::Layout::Tree
+  
+  ##
+  # :method: layout_horizon(opts,&block)
+  #
+  # Adds a Layout::Horizon to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+  mark_method :layout_horizon, Rubyvis::Layout::Horizon
+  
+  ##
+  # :method: layout_arc(opts,&block)
+  #
+  # Adds a Layout::Arc to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+  mark_method :layout_arc, Rubyvis::Layout::Arc    
+
+  ##
+  # :method: layout_matrix(opts,&block)
+  #
+  # Adds a Layout::Matrix to current mark. 
+  # 
+  # If a block is provided, the context will be defined differently if 
+  # parameter is provided
+  # * Without parameter: block executed inside context of new mark
+  # * With paramenter: block executed inside context of current mark. 
+  #   Paramenter references new mark
+  # 
+  # See Mark for examples of use    
+  mark_method :layout_matrix, Rubyvis::Layout::Matrix    
+  
+end
diff --git a/lib/rubyvis/mark/wedge.rb b/lib/rubyvis/mark/wedge.rb
new file mode 100644
index 0000000..21470c8
--- /dev/null
+++ b/lib/rubyvis/mark/wedge.rb
@@ -0,0 +1,145 @@
+module Rubyvis
+  # Alias for Rubyvis::Wedge
+  def self.Wedge
+    Rubyvis::Wedge
+  end
+  class Wedge < Mark
+    def type
+      "wedge"
+    end
+    @properties=Mark.properties.dup
+    
+    attr_accessor_dsl :start_angle, :end_angle, :angle, :inner_radius, :outer_radius, :line_width, [:stroke_style, lambda {|d| Rubyvis.color(d)}], [:fill_style, lambda {|d| Rubyvis.color(d)}]
+    
+    def self.defaults
+      a=Rubyvis.Colors.category20()
+      Wedge.new.mark_extend(Mark.defaults).start_angle(lambda  {s=self.sibling; s ? s.end_angle: -Math::PI.quo(2) } ).inner_radius( 0 ).line_width( 1.5 ).stroke_style( nil ).fill_style( lambda {a.scale(self.index)})
+    end
+    def mid_radius
+      (inner_radius+outer_radius) / 2.0
+    end
+    def mid_angle
+      (start_angle+end_angle) / 2.0
+    end
+    
+    def anchor(name)
+      that=self
+      partial=lambda {|s| s.inner_radius!=0 ? true : s.angle < 2*Math::PI}
+      mid_radius=lambda {|s| (s.inner_radius+s.outer_radius) / 2.0}
+      mid_angle=lambda {|s| (s.start_angle+s.end_angle) / 2.0 }
+      
+      mark_anchor(name).left(lambda {
+        s = self.scene.target[self.index];
+        if (partial.call(s))
+          case (self.name()) 
+          when "outer"
+            s.left + s.outer_radius * Math.cos(mid_angle.call(s))
+          when "inner"
+            s.left + s.inner_radius * Math.cos(mid_angle.call(s))
+          when "start"
+            s.left + mid_radius.call(s) * Math.cos(s.start_angle)
+          when "center"
+            s.left + mid_radius.call(s) * Math.cos(mid_angle.call(s))
+          when "end"
+            s.left + mid_radius.call(s) * Math.cos(s.end_angle)
+          else
+            s.left
+          end
+        else
+          s.left
+        end        
+      }).top(lambda {
+        s = self.scene.target[self.index];
+        if (partial.call(s))
+          case (self.name()) 
+          when "outer"
+            s.top + s.outer_radius * Math.sin(mid_angle.call(s))
+          when "inner"
+            s.top + s.inner_radius * Math.sin(mid_angle.call(s))
+          when "start"
+            s.top + mid_radius.call(s) * Math.sin(s.start_angle)
+          when "center"
+            s.top + mid_radius.call(s) * Math.sin(mid_angle.call(s))
+          when "end"
+            s.top + mid_radius.call(s) * Math.sin(s.end_angle)
+          else
+            s.top
+          end
+        else
+          s.top
+        end
+          
+      }).text_align(lambda {
+      s = self.scene.target[self.index];
+        if (partial.call(s))
+          case (self.name()) 
+          when 'outer'
+            that.upright(mid_angle.call(s)) ? 'right':'left'
+          when 'inner'
+            that.upright(mid_angle.call(s)) ? 'left':'right'
+          else 
+            'center'
+          end
+        else
+          'center'
+        end
+      }).text_baseline(lambda {
+      s = self.scene.target[self.index];
+        if (partial.call(s))
+          case (self.name()) 
+          when 'start'
+            that.upright(s.start_angle) ? 'top':'bottom'
+          when 'end'
+            that.upright(s.end_angle) ? 'bottom':'top'
+          else
+            'middle'
+          end
+        else
+          'middle'
+        end
+      }).text_angle(lambda {
+        s = self.scene.target[self.index];
+        a=0
+        if (partial.call(s))
+          case (self.name()) 
+          when 'center'
+            a=mid_angle.call(s)
+          when 'inner'
+            a=mid_angle.call(s)
+          when 'outer'
+            a=mid_angle.call(s)
+          when 'start'
+            a=s.start_angle
+          when 'end'
+            a=s.end_angle
+          end
+        end
+        that.upright(a) ? a: (a+Math::PI) 
+      })
+      
+    end
+    
+    def self.upright(angle)
+      angle=angle % (2*Math::PI)
+      angle=(angle<0) ? (2*Math::PI+angle) : angle
+      (angle < Math::PI/2.0) or (angle>=3*Math::PI / 2.0)  
+      
+    end
+    def upright(angle)
+      angle=angle % (2*Math::PI)
+      angle=(angle<0) ? (2*Math::PI+angle) : angle
+      (angle < Math::PI/2.0) or (angle>=3*Math::PI / 2.0)  
+    end
+    
+    def build_implied(s)
+      
+      if s.angle.nil?
+        s.angle = s.end_angle - s.start_angle 
+      elsif s.end_angle.nil?
+        s.end_angle = s.start_angle + s.angle
+      end
+      
+      mark_build_implied(s)
+    end
+  end
+end
diff --git a/lib/rubyvis/nest.rb b/lib/rubyvis/nest.rb
new file mode 100644
index 0000000..b53889d
--- /dev/null
+++ b/lib/rubyvis/nest.rb
@@ -0,0 +1,203 @@
+module Rubyvis
+  ##
+  # Returns a Nest operator for the specified array. This is a
+  # convenience factory method, equivalent to <tt>Nest.new(array)</tt>.
+  #
+  # @see Rubyvis::Nest
+  # @param {array} array an array of elements to nest.
+  # @returns {Nest} a nest operator for the specified array.
+  ##
+  def self.nest(array)
+    Nest.new(array)
+  end
+  # :stopdoc:
+  class NestedArray
+    attr_accessor :key, :values
+    def initialize(opts)
+      @key=opts[:key]
+      @values=opts[:values]
+    end
+    def ==(var)
+      key==var.key and values==var.values
+    end
+  end
+  # :startdoc: 
+  
+  # Represents a Nest operator for the specified array. Nesting
+  # allows elements in an array to be grouped into a hierarchical tree
+  # structure. The levels in the tree are specified by <i>key</i> functions. The
+  # leaf nodes of the tree can be sorted by value, while the internal nodes can
+  # be sorted by key. Finally, the tree can be returned either has a
+  # multidimensional array via Nest.entries, or as a hierarchical map via
+  # Nest.map. The Nest.rollup routine similarly returns a map, collapsing
+  # the elements in each leaf node using a summary function.
+  #
+  # For example, consider the following tabular data structure of Barley
+  # yields, from various sites in Minnesota during 1931-2:
+  #
+  #   { yield: 27.00, variety: "Manchuria", year: 1931, site: "University Farm" },
+  #   { yield: 48.87, variety: "Manchuria", year: 1931, site: "Waseca" },
+  #   { yield: 27.43, variety: "Manchuria", year: 1931, site: "Morris" }
+  #
+  # To facilitate visualization, it may be useful to nest the elements first by
+  # year, and then by variety, as follows:
+  #
+  #     var nest = Rubyvis.nest(yields)
+  #     .key(lambda {|d|  d.year})
+  #     .key(lambda {|d| d.variety})
+  #     .entries();
+  #
+  # This returns a nested array. Each element of the outer array is a key-values
+  # pair, listing the values for each distinct key:
+  #
+  # <pre>{ key: 1931, values: [
+  #   { key: "Manchuria", values: [
+  #       { yield: 27.00, variety: "Manchuria", year: 1931, site: "University Farm" },
+  #       { yield: 48.87, variety: "Manchuria", year: 1931, site: "Waseca" },
+  #       { yield: 27.43, variety: "Manchuria", year: 1931, site: "Morris" },
+  #       ...
+  #     ] },
+  #   { key: "Glabron", values: [
+  #       { yield: 43.07, variety: "Glabron", year: 1931, site: "University Farm" },
+  #       { yield: 55.20, variety: "Glabron", year: 1931, site: "Waseca" },
+  #       ...
+  #     ] },
+  #   ] },
+  # { key: 1932, values: ... }</pre>
+  #
+  # Further details, including sorting and rollup, is provided below on the
+  # corresponding methods.
+  class Nest
+    attr_accessor :array, :keys, :order
+    ##
+    # Constructs a nest operator for the specified array. This constructor should
+    # not be invoked directly; use Rubyvis.nest instead.
+    
+    def initialize(array)
+      @array=array
+      @keys=[]
+      @order=nil
+    end
+    def key(k)
+      @keys.push(k)
+      return self
+    end
+    def sort_keys(order=nil)
+      keys[keys.size-1].order = order.nil? ? Rubyvis.natural_order : order
+      return self
+    end
+    def sort_values(order=nil)
+      @order = order.nil? ? Rubyvis.natural_order : order
+      return self
+    end
+    
+    # Returns a hierarchical map of values. Each key adds one level to the
+    # hierarchy. With only a single key, the returned map will have a key for each
+    # distinct value of the key function; the correspond value with be an array of
+    # elements with that key value. If a second key is added, this will be a nested
+    # map. For example:
+    #
+    # <pre>Rubyvis.nest(yields)
+    #     .key(function(d) d.variety)
+    #     .key(function(d) d.site)
+    #     .map()</pre>
+    #
+    # returns a map <tt>m</tt> such that <tt>m[variety][site]</tt> is an array, a subset of
+    # <tt>yields</tt>, with each element having the given variety and site.
+    #
+    # @returns a hierarchical map of values    
+    def map
+      #i=0
+      map={} 
+      values=[]
+      @array.each_with_index {|x,j|
+        m=map
+        (@keys.size-1).times {|i|
+          k=@keys[i].call(x)
+          m[k]={} if (!m[k])
+          m=m[k]
+        }
+        k=@keys.last.call(x)
+        if(!m[k])
+          a=[]
+          values.push(a)
+          m[k]=a
+        end
+        m[k].push(x)
+      }
+      if(self.order)
+        values.each_with_index {|v,vi|
+          values[vi].sort!(&self.order)
+        }
+      end
+      map
+    end
+    
+    # Returns a hierarchical nested array. This method is similar to
+    # {@link pv.entries}, but works recursively on the entire hierarchy. Rather
+    # than returning a map like {@link #map}, this method returns a nested
+    # array. Each element of the array has a <tt>key</tt> and <tt>values</tt>
+    # field. For leaf nodes, the <tt>values</tt> array will be a subset of the
+    # underlying elements array; for non-leaf nodes, the <tt>values</tt> array will
+    # contain more key-values pairs.
+    #
+    # <p>For an example usage, see the {@link Nest} constructor.
+    #
+    # @returns a hierarchical nested array.
+    
+    def entries()
+      entries_sort(entries_entries(map),0)
+    end
+    def entries_entries(map)
+      array=[]
+      map.each_pair {|k,v|
+        array.push(NestedArray.new({:key=>k, :values=>(v.is_a? Array) ? v: entries_entries(v)}))
+      }
+      array
+    end
+    def entries_sort(array,i)
+      o=keys[i].order
+      if o
+        array.sort! {|a,b| o.call(a.key, b.key)}
+      end
+      i+=1
+      if (i<keys.size)
+        array.each {|v|
+          entries_sort(v, i)
+        }
+      end
+      array
+      
+    end
+    def rollup_rollup(map,f)
+      map.each_pair {|key,value|
+        if value.is_a? Array
+          map[key]=f.call(value)
+        else
+          rollup_rollup(value,f)
+        end
+      }
+      return map;
+    end
+    
+    # Returns a rollup map. The behavior of this method is the same as
+    # {@link #map}, except that the leaf values are replaced with the return value
+    # of the specified rollup function <tt>f</tt>. For example,
+    #
+    # <pre>pv.nest(yields)
+    #      .key(function(d) d.site)
+    #      .rollup(function(v) pv.median(v, function(d) d.yield))</pre>
+    #
+    # first groups yield data by site, and then returns a map from site to median
+    # yield for the given site.
+    #
+    # @see #map
+    # @param {function} f a rollup function.
+    # @returns a hierarchical map, with the leaf values computed by <tt>f</tt>.
+
+    
+    def rollup(f)
+      rollup_rollup(self.map, f)
+    end
+  end
+end
diff --git a/lib/rubyvis/property.rb b/lib/rubyvis/property.rb
new file mode 100644
index 0000000..6ae78c4
--- /dev/null
+++ b/lib/rubyvis/property.rb
@@ -0,0 +1,12 @@
+module Rubyvis
+  class Property
+    attr_accessor :name, :id, :value, :_type, :fixed
+    def initialize(opts=Hash.new)
+      @id=opts[:id]
+      @name=opts[:name]
+      @value=opts[:value]
+      @_type=opts[:_type]
+      @fixed=opts[:fixed]
+    end
+  end
+end
diff --git a/lib/rubyvis/scale.rb b/lib/rubyvis/scale.rb
new file mode 100644
index 0000000..f7267ed
--- /dev/null
+++ b/lib/rubyvis/scale.rb
@@ -0,0 +1,38 @@
+module Rubyvis
+  def self.Scale
+    Rubyvis::Scale
+  end
+  module Scale
+    def self.quantitative(*args)
+      Quantitative.new(*args)
+    end
+    def self.linear(*args)
+      Linear.new(*args)
+    end
+    def self.ordinal(*args)
+      Ordinal.new(*args)
+    end
+    def self.log(*args)
+      Log.new(*args)
+    end
+    def self.interpolator(start,_end)
+      if start.is_a? Numeric
+        return lambda {|t| t*(_end-start)+start}
+      end
+      start=Rubyvis.color(start).rgb()
+      _end = Rubyvis.color(_end).rgb()
+      return lambda {|t|
+        a=start.a*(1-t)+_end.a*t
+        a=0 if a<1e-5
+        return (start.a == 0) ? Rubyvis.rgb(_end.r, _end.g, _end.b, a) : ((_end.a == 0) ? Rubyvis.rgb(start.r, start.g, start.b, a) : Rubyvis.rgb(
+        (start.r * (1 - t) + _end.r * t).round,
+        (start.g * (1 - t) + _end.g * t).round,
+        (start.b * (1 - t) + _end.b * t).round, a))
+      }
+    end
+  end
+end
+require 'rubyvis/scale/quantitative.rb'
+require 'rubyvis/scale/linear.rb'
+require 'rubyvis/scale/ordinal.rb'
+require 'rubyvis/scale/log.rb'
diff --git a/lib/rubyvis/scale/linear.rb b/lib/rubyvis/scale/linear.rb
new file mode 100644
index 0000000..7153112
--- /dev/null
+++ b/lib/rubyvis/scale/linear.rb
@@ -0,0 +1,5 @@
+module Rubyvis
+  # See Quantitative for complete description of features
+  class Scale::Linear < Rubyvis::Scale::Quantitative
+  end
+end
diff --git a/lib/rubyvis/scale/log.rb b/lib/rubyvis/scale/log.rb
new file mode 100644
index 0000000..ae37891
--- /dev/null
+++ b/lib/rubyvis/scale/log.rb
@@ -0,0 +1,73 @@
+module Rubyvis
+  
+  class Scale::Log < Rubyvis::Scale::Quantitative
+    def initialize(*args)
+      super(*args)
+      @b=nil
+      @_p=nil
+      
+      base(10)
+    end
+    def log(x)
+      Math.log(x) / @_p.to_f
+    end
+    def pow(y)
+      @b**y
+    end
+    def base(v=nil)
+      if v
+        @b=v
+        @_p=Math.log(@b)
+        transform(lambda {|x| log(x)}, lambda {|x| pow(x)})
+        return self
+      end
+      return @b
+    end
+    def nice
+      d=domain
+      domain(Rubyvis.log_floor(d[0], at b), Rubyvis.log_ceil(d[1], at b))
+    end
+    # Returns an array of evenly-spaced, suitably-rounded values in the input
+    # domain. These values are frequently used in conjunction with
+    # Rule to display tick marks or grid lines.
+    # 
+    # Subdivisions set the number of division inside each base^x
+    # By default, is set to base
+    def ticks(subdivisions=nil)
+      d = domain
+      n = d[0] < 0
+      subdivisions||=@b
+      span=@b.to_f/subdivisions
+     # puts "dom: #{d[0]} -> #{n}"
+      
+      i = (n ? -log(-d[0]) : log(d[0])).floor
+      j = (n ? -log(-d[1]) : log(d[1])).ceil
+      ticks = [];
+      if n
+        ticks.push(-pow(-i))
+        (i..j).each {|ii|
+          ((@b-1)...0).each {|k|
+            ticks.push(-pow(-ii) * k)
+          }
+        }
+      else
+        (i...j).each {|ii|
+          (1..subdivisions).each {|k|
+            if k==1
+              ticks.push(pow(ii))
+            else
+              next if subdivisions==@b and k==2
+              ticks.push(pow(ii)*span*(k-1))
+            end
+          }
+        }
+        ticks.push(pow(j));
+      end
+      
+      # for (i = 0; ticks[i] < d[0]; i++); // strip small values
+      # for (j = ticks.length; ticks[j - 1] > d[1]; j--); // strip big values
+      # return ticks.slice(i, j);
+      ticks.find_all {|v| v>=d[0] and v<=d[1]}
+    end
+  end
+end
diff --git a/lib/rubyvis/scale/ordinal.rb b/lib/rubyvis/scale/ordinal.rb
new file mode 100644
index 0000000..5e5dd32
--- /dev/null
+++ b/lib/rubyvis/scale/ordinal.rb
@@ -0,0 +1,206 @@
+module Rubyvis
+  # Represents an ordinal scale. <style
+  # type="text/css">sub{line-height:0}</style> An ordinal scale represents a
+  # pairwise mapping from <i>n</i> discrete values in the input domain to
+  # <i>n</i> discrete values in the output range. For example, an ordinal scale
+  # might map a domain of species ["setosa", "versicolor", "virginica"] to colors
+  # ["red", "green", "blue"]. Thus, saying
+  #
+  #   .fill_style(lambda {|d|
+  #         case (d.species)
+  #           when "setosa"
+  #             "red"
+  #           when "versicolor"
+  #             "green"
+  #           when "virginica"
+  #             "blue"
+  #         }
+  #       )
+  #
+  # is equivalent to
+  #
+  #   .fill_style(Rubyvis::Scale.ordinal("setosa", "versicolor", "virginica")
+  #         .range("red", "green", "blue")
+  #         .by(lambda {|d| d.species}))</pre>
+  #
+  # If the mapping from species to color does not need to be specified
+  # explicitly, the domain can be omitted. In this case it will be inferred
+  # lazily from the data:
+  #
+  #   .fill_style(Rubyvis.colors("red", "green", "blue")
+  #         .by(lambda {|d| d.species}))</pre>
+  #
+  # When the domain is inferred, the first time the scale is invoked, the first
+  # element from the range will be returned. Subsequent calls with unique values
+  # will return subsequent elements from the range. If the inferred domain grows
+  # larger than the range, range values will be reused. However, it is strongly
+  # recommended that the domain and the range contain the same number of
+  # elements.
+  #
+  # A range can be discretized from a continuous interval (e.g., for pixel
+  # positioning) by using split, split_flush or
+  # split_banded after the domain has been set. For example, if
+  # <tt>states</tt> is an array of the fifty U.S. state names, the state name can
+  # be encoded in the left position:
+  #
+  #   .left(Rubyvis::Scale.ordinal(states)
+  #         .split(0, 640)
+  #         .by(lambda {|d| d.state}))
+  #
+  # N.B.: ordinal scales are not invertible (at least not yet), since the
+  # domain and range and discontinuous. A workaround is to use a linear scale.
+  class Scale::Ordinal
+    # range band, after use split_banded
+    # equivalen to protovis scale.range().band
+    attr_reader :range_band
+    # Returns an ordinal scale for the specified domain. The arguments to this
+    # constructor are optional, and equivalent to calling domain    
+    def initialize(*args)
+      @d=[] # domain
+      @i={}
+      @r=[]
+      @range_band=nil
+      @band=0
+      domain(*args)
+    end
+    
+    # Return 
+    #   lambda {|d| scale_object.scale(d)}
+    # Useful as value on dynamic properties
+    #   scale=Rubyvis.ordinal("red","blue","green")
+    #   bar.fill_style(scale)
+    # is the same as
+    #   bar.fill_style(lambda {|x| scale.scale(x)})
+    def to_proc
+      that=self
+      lambda {|*args| args[0] ? that.scale(args[0]) : nil }
+    end
+    def scale(x)
+      if @i[x].nil?
+        @d.push(x)
+        @i[x]=@d.size-1
+      end
+      @r[@i[x] % @r.size]
+    end
+    alias :[] :scale      
+    # Sets or gets the input domain. This method can be invoked several ways:
+    #
+    # <p>1. <tt>domain(values...)</tt>
+    #
+    # <p>Specifying the domain as a series of values is the most explicit and
+    # recommended approach. However, if the domain values are derived from data,
+    # you may find the second method more appropriate.
+    #
+    # <p>2. <tt>domain(array, f)</tt>
+    #
+    # <p>Rather than enumerating the domain values as explicit arguments to this
+    # method, you can specify a single argument of an array. In addition, you can
+    # specify an optional accessor function to extract the domain values from the
+    # array.
+    #
+    # <p>3. <tt>domain()</tt>
+    #
+    # <p>Invoking the <tt>domain</tt> method with no arguments returns the
+    # current domain as an array.
+    def domain(*arguments)
+      array, f=arguments[0],arguments[1]
+      if(arguments.size>0)
+      array= (array.is_a? Array) ? ((arguments.size>1) ? Rubyvis.map(array,f) : array) : arguments.dup
+        @d=array.uniq
+        @i=Rubyvis.numerate(@d)
+        return self
+      end
+      @d
+    end
+    
+    # Sets the range from the given continuous interval. The interval [<i>
+    # min</i>, <i>max</i>] is subdivided into <i>n</i> equispaced bands,
+    # where <i>n</i> is the number of (unique) values in the domain. The first
+    # and last band are offset from the edge of the range by the distance between bands.
+    # 
+    # <p>The band width argument, <tt>band</tt>, is typically in the range [0, 1]
+    # and defaults to 1. This fraction corresponds to the amount of space in the
+    # range to allocate to the bands, as opposed to padding. A value of 0.5
+    # means  that the band width will be equal to the padding width. 
+    # The computed  absolute band width can be retrieved from the range as
+    # <tt>scale.range_band</tt>.
+    #
+    # <p>If the band width argument is negative, this method will allocate bands
+    # of a <i>fixed</i> width <tt>-band</tt>, rather than a relative fraction of
+    # the available space.
+    #
+    # <p>Tip: to inset the bands by a fixed amount <tt>p</tt>, specify a minimum
+    # value of <tt>min + p</tt> (or simply <tt>p</tt>, if <tt>min</tt> is
+    # 0). Then set the mark width to <tt>scale.range_band - p</tt>.
+    #
+    # <p>This method must be called <i>after</i> the domain is set.
+    
+    def split_banded(*arguments) # :args: (min,max,band=1)
+      min,max,band=arguments
+      band=1 if (arguments.size < 3)
+      if (band < 0) 
+        
+        n = self.domain().size
+        total = -band * n
+        remaining = max - min - total
+        padding = remaining / (n + 1).to_f
+        @r = Rubyvis.range(min + padding, max, padding - band);
+        @range_band = -band;
+      else
+        step = (max - min) / (self.domain().size + (1 - band))
+        @r = Rubyvis.range(min + step * (1 - band), max, step);
+        @range_band = step * band;
+      end
+      return self
+    end
+    def range(*arguments)
+      array, f = arguments[0],arguments[1]
+      if(arguments.size>0)
+        @r=(array.is_a? Array) ? ((arguments.size>1) ? array.map(&f) : array) : arguments.dup
+        if @r[0].is_a? String
+          @r=@r.map {|i| Rubyvis.color(i)}
+        end
+        return self
+      end
+      @r
+    end
+    
+    # Sets the range from the given continuous interval. The interval [<i>
+    # min</i>, <i>max</i>] is subdivided into <i>n</i> equispaced points,
+    # where <i>n</i> is the number of (unique) values in the domain. The first
+    # and last point are offset from the edge of the range by half the distance
+    # between points.
+    #
+    # <p>This method must be called <i>after</i> the domain is set.
+    def split(min,max)
+      step=(max-min).quo(domain().size)
+      @r=Rubyvis.range(min+step.quo(2),max,step)
+      self
+    end
+    
+    # Sets the range from the given continuous interval. The interval
+    # [<i>min</i>, <i>max</i>] is subdivided into <i>n</i> equispaced points,
+    # where <i>n</i> is the number of (unique) values in the domain. The first
+    # and last point are exactly on the edge of the range.
+    #
+    # <p>This method must be called <i>after</i> the domain is set.
+    #
+    # * @param {number} min minimum value of the output range.
+    # * @param {number} max maximum value of the output range.
+    # * @returns {pv.Scale.ordinal} <tt>this</tt>.
+    # * @see Ordinal.split
+    
+    def split_flush(min,max)
+      n = self.domain().size
+      step = (max - min) / (n - 1).to_f
+      @r = (n == 1) ? [(min + max) / 2.0] : Rubyvis.range(min, max + step/2.0, step)
+      self
+    end
+    def by(f)
+      that=self
+      lambda {|*args|
+        that.scale(f.js_apply(self,args))
+      }
+    end
+  end
+end
diff --git a/lib/rubyvis/scale/quantitative.rb b/lib/rubyvis/scale/quantitative.rb
new file mode 100644
index 0000000..c3e6364
--- /dev/null
+++ b/lib/rubyvis/scale/quantitative.rb
@@ -0,0 +1,444 @@
+module Rubyvis
+  # Represents an abstract quantitative scale; a function that performs a
+  # numeric transformation. This class is typically not used directly; see one of
+  # the quantitative scale implementations (linear, log, root, etc.)
+  # instead. <style type="text/css">sub{line-height:0}</style> A quantitative
+  # scale represents a 1-dimensional transformation from a numeric domain of
+  # input data [<i>d<sub>0</sub></i>, <i>d<sub>1</sub></i>] to a numeric range of
+  # pixels [<i>r<sub>0</sub></i>, <i>r<sub>1</sub></i>]. In addition to
+  # readability, scales offer several useful features:
+  #
+  # <p>1. The range can be expressed in colors, rather than pixels. For example:
+  #
+  #   .fill_style(Scale.linear(0, 100).range("red", "green"))
+  #
+  # will fill the marks "red" on an input value of 0, "green" on an input value
+  # of 100, and some color in-between for intermediate values.
+  #
+  # <p>2. The domain and range can be subdivided for a non-uniform
+  # transformation. For example, you may want a diverging color scale that is
+  # increasingly red for negative values, and increasingly green for positive
+  # values:
+  #
+  #   .fill_style(Scale.linear(-1, 0, 1).range("red", "white", "green"))</pre>
+  #
+  # The domain can be specified as a series of <i>n</i> monotonically-increasing
+  # values; the range must also be specified as <i>n</i> values, resulting in
+  # <i>n - 1</i> contiguous linear scales.
+  #
+  # <p>3. Quantitative scales can be inverted for interaction. The
+  # invert() method takes a value in the output range, and returns the
+  # corresponding value in the input domain. This is frequently used to convert
+  # the mouse location (see Mark#mouse) to a value in the input
+  # domain. Note that inversion is only supported for numeric ranges, and not
+  # colors.
+  #
+  # <p>4. A scale can be queried for reasonable "tick" values. The ticks()
+  # method provides a convenient way to get a series of evenly-spaced rounded
+  # values in the input domain. Frequently these are used in conjunction with
+  # Rule to display tick marks or grid lines.
+  #
+  # <p>5. A scale can be "niced" to extend the domain to suitable rounded
+  # numbers. If the minimum and maximum of the domain are messy because they are
+  # derived from data, you can use nice() to round these values down and
+  # up to even numbers.
+  #
+  # @see Scale.linear
+  # @see Scale.log
+  # @see Scale.root
+  class Scale::Quantitative
+    include Rubyvis::Scale
+    attr_reader :l
+    # Returns a default quantitative, linear, scale for the specified domain. The
+    # arguments to this constructor are optional, and equivalent to calling
+    # domain. The default domain and range are [0,1].
+    #
+    # This constructor is typically not used directly; see one of the
+    # quantitative scale implementations instead.
+    # @param {number...} domain... optional domain values.
+    def initialize(*args)
+      @d=[0,1] # domain
+      @l=[0,1] # transformed domain
+      @r=[0,1] # default range
+      @i=[Rubyvis.identity] # default interpolator
+      @type=:to_f # default type
+      @n=false
+      @f=Rubyvis.identity # default forward transformation
+      @g=Rubyvis.identity
+      @tick_format=lambda {|x|
+        if x.is_a? Numeric
+          ((x.to_f-x.to_i==0) ? x.to_i : x.to_f).to_s
+        else
+          ""
+        end
+      }
+      domain(*args)
+    end
+    
+    # Deprecated
+    def new_date(x=nil) # :nodoc:
+      x.nil? ? Time.new() : Time.at(x)
+    end
+    # Return 
+    #   lambda {|d| scale_object.scale(d)}
+    # Useful as value on dynamic properties
+    #   scale=Rubyvis.linear(0,1000)
+    #   bar.width(scale)
+    # is the same as
+    #   bar.width(lambda {|x| scale.scale(x)})
+    def to_proc
+      that=self
+      lambda {|*args|  args[0] ? that.scale(args[0]) : nil }
+    end
+    # Transform value +x+ according to domain and range
+    def scale(x)
+      return nil if x.nil?
+      x=x.to_f
+      j=Rubyvis.search(@d, x)
+      j=-j-2 if (j<0)
+      j=[0,[@i.size-1,j].min].max
+      # p @l
+      # puts "Primero #{j}: #{@f.call(x) - @l[j]}"
+      # puts "Segundo #{(@l[j + 1] - @l[j])}"
+      @i[j].call((@f.call(x) - @l[j]) .quo(@l[j + 1] - @l[j]));
+    end
+    alias :[] :scale      
+    def transform(forward, inverse)
+      @f=lambda {|x| @n ? -forward.call(-x) : forward.call(x); }
+      @g=lambda {|y| @n ? -inverse.call(-y) : inverse.call(y); }
+      @l=@d.map{|v| @f.call(v)}
+      self
+    end
+    private :transform
+    # Sets or gets the input domain. This method can be invoked several ways:
+    #
+    # <p>1. <tt>domain(min, ..., max)</tt>
+    #
+    # <p>Specifying the domain as a series of numbers is the most explicit and
+    # recommended approach. Most commonly, two numbers are specified: the minimum
+    # and maximum value. However, for a diverging scale, or other subdivided
+    # non-uniform scales, multiple values can be specified. Values can be derived
+    # from data using Rubyvis.min and Rubyvis.max. For example:
+    #
+    #   .domain(0, Rubyvis.max(array))
+    #
+    # An alternative method for deriving minimum and maximum values from data
+    # follows.
+    #
+    # <p>2. <tt>domain(array, minf, maxf)</tt>
+    #
+    # <p>When both the minimum and maximum value are derived from data, the
+    # arguments to the <tt>domain</tt> method can be specified as the array of
+    # data, followed by zero, one or two accessor functions. For example, if the
+    # array of data is just an array of numbers:
+    #
+    #   .domain(array)
+    #
+    # On the other hand, if the array elements are objects representing stock
+    # values per day, and the domain should consider the stock's daily low and
+    # daily high:
+    #
+    #   .domain(array, lambda {|d|  d.low}, lambda {|d| d.high})
+    #
+    # The first method of setting the domain is preferred because it is more
+    # explicit; setting the domain using this second method should be used only
+    # if brevity is required.
+    #
+    # <p>3. <tt>domain()</tt>
+    #
+    # <p>Invoking the <tt>domain</tt> method with no arguments returns the
+    # current domain as an array of numbers.
+    def domain(*arguments)
+      array,min,max=arguments
+      o=nil
+      if (arguments.size>0)
+        if array.is_a? Array 
+          min = Rubyvis.identity if (arguments.size < 2)
+          max = min if (arguments.size < 3)
+          o = [array[0]].min if array.size>0
+          @d = array.size>0 ? [Rubyvis.min(array, min), Rubyvis.max(array, max)] : []
+        else 
+          o = array
+          @d = arguments.map {|i| i.to_f}
+        end
+        
+        if !@d.size 
+          @d = [-Infinity, Infinity];
+        elsif (@d.size == 1) 
+          @d = [@d.first, @d.first]
+        end
+        
+        @n = (@d.first.to_f<0 or @d.last.to_f<0)
+        @l=@d.map{|v| @f.call(v)}
+        
+        @type = (o.is_a? Time) ? :time : :number;
+        return self
+      end
+      # TODO: Fix this.
+      @d.map{|v| 
+        case @type
+        when :number
+          v.to_f
+        when :time
+          Time.at(v)
+        else 
+          v
+        end
+      }
+    end
+    
+    # Sets or gets the output range. This method can be invoked several ways:
+    #
+    # <p>1. <tt>range(min, ..., max)</tt>
+    #
+    # <p>The range may be specified as a series of numbers or colors. Most
+    # commonly, two numbers are specified: the minimum and maximum pixel values.
+    # For a color scale, values may be specified as {@link Rubyvis.Color}s or
+    # equivalent strings. For a diverging scale, or other subdivided non-uniform
+    # scales, multiple values can be specified. For example:
+    #
+    #   .range("red", "white", "green")
+    #
+    # <p>Currently, only numbers and colors are supported as range values. The
+    # number of range values must exactly match the number of domain values, or
+    # the behavior of the scale is undefined.
+    #
+    # <p>2. <tt>range()</tt>
+    #
+    # <p>Invoking the <tt>range</tt> method with no arguments returns the current
+    # range as an array of numbers or colors.
+    # :call-seq:
+    #   range(min,...,max)
+    #   range()
+    def range(*arguments)
+      if (arguments.size>0) 
+        @r = arguments.dup
+        if (@r.size==0)
+          @r = [-Infinity, Infinity];
+        elsif (@r.size == 1)
+          @r = [@r[0], @r[0]]
+        end
+        @i=(@r.size-1).times.map do |j|
+          Rubyvis::Scale.interpolator(@r[j], @r[j + 1]);
+        end
+        return self
+      end
+      @r
+    end
+    
+    def invert(y)
+      j=Rubyvis.search(@r, y)
+      j=-j-2 if j<0
+      j = [0, [@i.size - 1, j].min].max
+      
+      val=@g.call(@l[j] + (y - @r[j]).quo(@r[j + 1] - @r[j]) * (@l[j + 1] - @l[j]))
+      @type==:time ? Time.at(val) : val
+    end
+    
+    def type(v=nil)
+      return @type if v.nil?
+      case @type
+        when Numeric
+          v.to_f
+        when Date
+          raise "Not implemented yet"
+      end
+    end
+    def ticks_floor(d,prec) # :nodoc:
+      ar=d.to_a
+      #p ar
+      # [ sec, min, hour, day, month, year, wday, yday, isdst, zone ]
+      case(prec) 
+        when 31536e6
+          ar[4]=1
+        when 2592e6
+          ar[3]=1
+        when 6048e5
+          ar[3]=ar[3]-ar[6] if (prec == 6048e5)
+        when 864e5
+          ar[2]=0
+        when 36e5
+          ar[1]=0
+        when 6e4
+          ar[0]=0
+        when 1e3
+          # do nothing
+      end
+      to_date(ar)
+    end
+    
+    private :ticks_floor
+    
+    def to_date(d) # :nodoc:
+      
+      Time.utc(*d)
+    end
+    # Returns an array of evenly-spaced, suitably-rounded values in the input
+    # domain. This method attempts to return between 5 and 10 tick values. These
+    # values are frequently used in conjunction with Rule to display
+    # tick marks or grid lines.
+    #
+    # If start and end of domain are the same, returns only one tick value
+    # @todo: fix for dates and n>10
+    def ticks(m=nil) # :args: (number_of_ticks=nil)
+      start = @d.first
+      _end = @d.last
+      return [start] if start==_end
+      reverse = _end < start
+      min = reverse ? _end : start
+      max = reverse ? start : _end
+      span = max - min
+      # Special case: empty, invalid or infinite span.
+      if (!span or (span.is_a? Float and span.infinite?)) 
+        @tick_format= Rubyvis.Format.date("%x") if (@type == newDate) 
+        return [type(min)];
+      end
+      
+      #/* Special case: dates. */
+      if (@type == :time) 
+      #/* Floor the date d given the precision p. */
+      precision, format, increment, step = 1,1,1,1
+      if (span >= 3 * 31536e6 / 1000.0) 
+        precision = 31536e6
+        format = "%Y"
+        increment = lambda {|d|  Time.at(d.to_f+(step*365*24*60*60)) }
+      elsif (span >= 3 * 2592e6 / 1000.0) 
+        precision = 2592e6;
+        format = "%m/%Y";
+        increment = lambda {|d| Time.at(d.to_f+(step*30*24*60*60)) }
+      elsif (span >= 3 * 6048e5 / 1000.0) 
+        precision = 6048e5;
+        format = "%m/%d";
+        increment = lambda {|d| Time.at(d.to_f+(step*7*24*60*60)) }
+      elsif (span >= 3 * 864e5 / 1000.0) 
+        precision = 864e5;
+        format = "%m/%d";
+        increment = lambda {|d| Time.at(d.to_f+(step*24*60*60)) }
+      elsif (span >= 3 * 36e5 / 1000.0) 
+        precision = 36e5;
+        format = "%I:%M %p";
+        increment = lambda {|d| Time.at(d.to_f+(step*60*60)) }
+      elsif (span >= 3 * 6e4 / 1000.0 ) 
+        precision = 6e4;
+        format = "%I:%M %p";
+        increment = lambda {|d| Time.at(d.to_f+(step*60)) }
+      elsif (span >= 3 * 1e3 / 1000.0) 
+        precision = 1e3;
+        format = "%I:%M:%S";
+        increment = lambda {|d|  Time.at(d.to_f+(step)) }
+      else 
+        precision = 1;
+        format = "%S.%Qs";
+        increment = lambda {|d|  Time.at(d.to_f+(step/1000.0)) }
+      end
+      
+      @tick_format = Rubyvis.Format.date(format);
+      date = Time.at(min.to_f)
+      dates = []
+      date = ticks_floor(date,precision)
+      # If we'd generate too many ticks, skip some!.
+      n = span / (precision/1000.0)
+      # FIX FROM HERE
+      if (n > 10) 
+        case (precision) 
+        when 36e5
+          step = (n > 20) ? 6 : 3;
+          date.setHours(Math.floor(date.getHours() / step) * step);
+        when 2592e6
+          step = 3; # seasons
+          ar=date.to_a
+          ar[4]=(date.month/step.to_f).floor*step
+          date=to_date(ar)
+        when 6e4
+          step = (n > 30) ? 15 : ((n > 15) ? 10 : 5);
+          date.setMinutes(Math.floor(date.getMinutes() / step) * step);
+        when 1e3
+          step = (n > 90) ? 15 : ((n > 60) ? 10 : 5);
+          date.setSeconds(Math.floor(date.getSeconds() / step) * step);
+        when 1
+          step = (n > 1000) ? 250 : ((n > 200) ? 100 : ((n > 100) ? 50 : ((n > 50) ? 25 : 5)));
+          date.setMilliseconds(Math.floor(date.getMilliseconds() / step) * step);
+        else
+          step = Rubyvis.log_ceil(n / 15, 10);
+          if (n / step < 2) 
+            step =step.quo(5)
+          elsif (n / step < 5)
+            step = step.quo(2)
+          end
+          date.setFullYear((date.getFullYear().quo(step)).floor * step);
+        end
+      end
+      # END FIX
+        while (true)
+          date=increment.call(date)
+          break if (date.to_f > max.to_f)
+          dates.push(date)
+        end
+        return reverse ? dates.reverse() : dates;
+      end
+      
+      # Normal case: numbers. 
+      m||= 10
+      
+      step = Rubyvis.log_floor(span.quo(m), 10)
+      err = m.quo(span.quo(step))
+      if (err <= 0.15)
+        step = step*10
+      elsif (err <= 0.35)
+        step = step*5
+      elsif (err <= 0.75)
+        step = step*2
+      end
+      start = (min.quo(step)).ceil * step
+      _end = (max.quo(step)).floor * step
+      
+      @tick_format= Rubyvis.Format.number.fraction_digits([0, -(Rubyvis.log(step, 10) + 0.01).floor].max).to_proc
+      
+      ticks = Rubyvis.range(start, _end + step, step)
+      
+      return reverse ? ticks.reverse() : ticks;
+    end
+    
+    # Returns a Proc that formats the specified tick value using the appropriate precision, based on
+    # the step interval between tick marks. If ticks() has not been called,
+    # the argument is converted to a string, but no formatting is applied.
+    #   scale.tick_format.call(value)
+    #
+    def tick_format
+      @tick_format
+    end
+    
+    # "Nices" this scale, extending the bounds of the input domain to
+    # evenly-rounded values. Nicing is useful if the domain is computed
+    # dynamically from data, and may be irregular. For example, given a domain of
+    # [0.20147987687960267, 0.996679553296417], a call to <tt>nice()</tt> might
+    # extend the domain to [0.2, 1].
+    #
+    # This method must be invoked each time after setting the domain.
+    def nice
+      return self if @d.size!=2
+      start=@d.first
+      _end=@d[@d.size-1]
+      reverse=_end<start
+      min=reverse ? _end : start
+      max = reverse ? start : _end
+      span=max-min
+      
+      return self if(!span or span.infinite?)
+      
+      step=10**((Math::log(span).quo(Math::log(10))).round-1)
+      @d=[(min.quo(step)).floor*step, (max.quo(step)).ceil*step]
+      @d.reverse if  reverse
+      @l=@d.map {|v| @f.call(v)}
+      self
+    end
+    def by(f)
+      that=self
+      lambda {|*args|
+        that.scale(f.js_apply(self,args))
+      }
+    end
+    
+    
+  end
+end
diff --git a/lib/rubyvis/scene/svg_area.rb b/lib/rubyvis/scene/svg_area.rb
new file mode 100644
index 0000000..24c1faa
--- /dev/null
+++ b/lib/rubyvis/scene/svg_area.rb
@@ -0,0 +1,211 @@
+module Rubyvis
+  module SvgScene
+    def self.area(scenes)
+      #e = scenes._g.elements[1]
+      e=scenes._g.get_element(1)
+      return e if scenes.size==0
+      s=scenes[0]
+      # segmented
+      return self.area_segment(scenes) if (s.segmented) 
+      # visible
+      return e if (!s.visible)
+      fill = s.fill_style
+      stroke = s.stroke_style
+      return e if (fill.opacity==0 and stroke.opacity==0)
+      
+      # Computes the straight path for the range [i, j]
+      path=lambda {|ii,j|
+        p1 = []
+        p2 = []
+        k=j
+        (ii..k).each {|i|
+          si = scenes[i]
+          sj = scenes[j]
+          pi = "#{si.left},#{si.top}"
+          pj = "#{(sj.left + sj.width)},#{(sj.top + sj.height)}"
+          puts "#{i}:"+pi+","+pj if $DEBUG
+          #/* interpolate */
+          
+          if (i < k)
+            sk = scenes[i + 1]
+            sl = scenes[j - 1]
+            case (s.interpolate) 
+              when "step-before"
+                pi = pi+"V#{sk.top}"
+                pj = pj+"H#{sl.left + sl.width}"
+              
+              when "step-after"
+                pi = pi+"H#{sk.left}"
+                pj = pj+"V#{sl.top + sl.height}"
+            end
+          end
+    
+          p1.push(pi)
+          p2.push(pj)
+          j=j-1
+        }
+        (p1+p2).join("L");
+      }
+        
+      # @private Computes the curved path for the range [i, j]. */
+      path_curve=lambda {|ii, j|
+        pointsT = []
+        pointsB = []
+        pathT=nil
+        pathB=nil
+        
+        
+        k=j
+        (ii..k).each {|i|
+          sj = scenes[j];
+          pointsT.push(scenes[i])
+          pointsB.push(OpenStruct.new({:left=> sj.left + sj.width, :top=> sj.top + sj.height}))
+          j=j-1
+        }
+        
+        if (s.interpolate == "basis") 
+          pathT = Rubyvis::SvgScene.curve_basis(pointsT)
+          pathB = Rubyvis::SvgScene.curve_basis(pointsB)
+        elsif (s.interpolate == "cardinal") 
+            pathT = Rubyvis::SvgScene.curve_cardinal(pointsT, s.tension);
+            pathB = Rubyvis::SvgScene.curve_cardinal(pointsB, s.tension);
+        elsif # monotone
+          pathT = Rubyvis::SvgScene.curve_monotone(pointsT);
+          pathB = Rubyvis::SvgScene.curve_monotone(pointsB);
+        end
+        
+        "#{pointsT[0].left },#{ pointsT[0].top }#{ pathT }L#{ pointsB[0].left},#{pointsB[0].top}#{pathB}"
+      }
+        
+      #/* points */
+      d = []
+      si=nil
+      sj=nil
+      i=0
+      # puts "Scenes:#{scenes.size}, interpolation:#{scenes[0].interpolate}"
+      
+      while(i < scenes.size)
+        si = scenes[i]
+        if (si.width==0 and si.height==0)
+          i+=1
+          next
+        end
+        
+        j=i+1
+        while(j<scenes.size) do
+          sj=scenes[j]
+          break if sj.width==0 and sj.height==0
+          j+=1
+        end
+        
+        puts "j:#{j}" if $DEBUG
+        
+        i=i-1 if (i!=0 and (s.interpolate != "step-after"))
+        
+        j=j+1 if ((j < scenes.size) and (s.interpolate != "step-before"))
+        
+        d.push(((j - i > 2 and (s.interpolate == "basis" or s.interpolate == "cardinal" or s.interpolate == "monotone")) ? path_curve : path).call(i, j - 1))
+        
+        i = j - 1
+        i+=1
+        
+      end
+      
+      return e if d.size==0
+    
+      e = self.expect(e, "path", {
+        "shape-rendering"=> s.antialias ? nil : "crispEdges",
+        "pointer-events"=> s.events,
+        "cursor"=> s.cursor,
+        "d"=> "M" + d.join("ZM") + "Z",
+        "fill"=> fill.color,
+        "fill-opacity"=> fill.opacity==0 ? nil : fill.opacity,
+        "stroke"=> stroke.color,
+        "stroke-opacity"=> stroke.opacity==0 ? nil : stroke.opacity,
+        "stroke-width"=> stroke.opacity!=0 ? s.line_width / self.scale : nil
+      })
+      self.append(e, scenes, 0);
+    end
+        
+    def self.area_segment(scenes)
+      e=scenes._g.get_element(1)
+      #e = scenes._g.elements[1]
+      s = scenes[0]
+      pathsT=nil
+      pathsB=nil
+      if (s.interpolate == "basis" or s.interpolate == "cardinal" or s.interpolate == "monotone") 
+        pointsT = []
+        pointsB = []
+        n=scenes.size
+        n.times {|i|
+          sj = scenes[n - i - 1]
+          pointsT.push(scenes[i])
+          pointsB.push(OpenStruct.new({:left=> sj.left + sj.width, :top=> sj.top + sj.height}));
+        }
+    
+        if (s.interpolate == "basis") 
+          pathsT = Rubyvis::SvgScene.curve_basis_segments(pointsT)
+          pathsB = Rubyvis::SvgScene.curve_basis_segments(pointsB)
+        elsif (s.interpolate == "cardinal")
+            pathsT = Rubyvis::SvgScene.curve_cardinal_segments(pointsT, s.tension);
+            pathsB = Rubyvis::SvgScene.curve_cardinal_segments(pointsB, s.tension);
+        elsif # monotone
+          pathsT = Rubyvis::SvgScene.curve_monotone_segments(pointsT)
+          pathsB = Rubyvis::SvgScene.curve_monotone_segments(pointsB)
+        end
+      end
+      
+      n=scenes.size-1
+      n.times {|i|
+        
+        s1 = scenes[i]
+        s2 = scenes[i + 1]
+    
+        # /* visible */
+        next if (!s1.visible or !s2.visible)
+        
+        fill = s1.fill_style
+        stroke = s1.stroke_style            
+        next if (fill.opacity==0 and stroke.opacity==0)
+        
+        d=nil
+        if (pathsT) 
+          pathT = pathsT[i]
+          pb=pathsB[n - i - 1]
+          pathB = "L" + pb[1,pb.size-1]
+          d = pathT + pathB + "Z";
+        else 
+          #/* interpolate */
+          si = s1
+          sj = s2
+          
+          case (s1.interpolate) 
+            when "step-before"
+              si = s2
+            when "step-after"
+              sj = s1
+          end
+          
+    
+          #/* path */
+          d = "M#{s1.left},#{si.top}L#{s2.left},#{sj.top }L#{s2.left + s2.width},#{sj.top + sj.height}L#{s1.left + s1.width},#{si.top + si.height}Z"
+        end
+    
+        e = self.expect(e, "path", {
+            "shape-rendering"=> s1.antialias ? nil : "crispEdges",
+            "pointer-events"=> s1.events,
+            "cursor"=> s1.cursor,
+            "d"=> d,
+            "fill"=> fill.color,
+            "fill-opacity"=> fill.opacity==0 ? nil : fill.opacity,
+          "stroke"=> stroke.color,
+          "stroke-opacity"=> stroke.opacity==0 ? nil : stroke.opacity,
+          "stroke-width"=> stroke.opacity!=0 ? s1.line_width / self.scale : nil
+          });
+        e = self.append(e, scenes, i);
+      }
+      return e
+    end
+  end
+end
+
diff --git a/lib/rubyvis/scene/svg_bar.rb b/lib/rubyvis/scene/svg_bar.rb
new file mode 100644
index 0000000..ca89b50
--- /dev/null
+++ b/lib/rubyvis/scene/svg_bar.rb
@@ -0,0 +1,32 @@
+module Rubyvis
+  module SvgScene
+    def self.bar(scenes)
+      #e=scenes._g.elements[1]
+      e=scenes._g.get_element(1)
+      scenes.each_with_index do |s,i|
+        next unless s.visible
+        fill=s.fill_style
+        stroke=s.stroke_style
+        next if(fill.opacity==0 and stroke.opacity==0)
+        e=SvgScene.expect(e, 'rect', {
+          "shape-rendering"=> s.antialias ? nil : "crispEdges",
+          "pointer-events"=> s.events,
+          "cursor"=> s.cursor,
+          "x"=> s.left,
+          "y"=> s.top,
+          "width"=> [1E-10, s.width].max,
+          "height"=> [1E-10, s.height].max,
+          "fill"=> fill.color,
+          "fill-opacity"=> (fill.opacity==0) ? nil : fill.opacity,
+          "stroke"=> stroke.color,
+          "stroke-opacity"=> (stroke.opacity==0) ? nil : stroke.opacity,
+          "stroke-width"=> stroke.opacity ? s.line_width / SvgScene.scale.to_f : nil
+        })
+
+        e=SvgScene.append(e,scenes,i)
+
+      end
+      e
+    end
+  end
+end
diff --git a/lib/rubyvis/scene/svg_curve.rb b/lib/rubyvis/scene/svg_curve.rb
new file mode 100644
index 0000000..6f15546
--- /dev/null
+++ b/lib/rubyvis/scene/svg_curve.rb
@@ -0,0 +1,340 @@
+module Rubyvis::SvgScene
+  class PathBasis #:nodoc:
+    def initialize(p0,p1,p2,p3)
+      @p0=p0
+      @p1=p1
+      @p2=p2
+      @p3=p3
+    end
+    attr_accessor :p0,:p1,:p2,:p3
+    
+    #
+    # Matrix to transform basis (b-spline) control points to bezier control
+    # points. Derived from FvD 11.2.8.
+    #
+    
+    def basis
+      [
+      [ 1/6.0, 2/3.0, 1/6.0,   0 ],
+      [   0, 2/3.0, 1/3.0,   0 ],
+      [   0, 1/3.0, 2/3.0,   0 ],
+      [   0, 1/6.0, 2/3.0, 1/6.0 ]
+      ]
+    end
+    # Returns the point that is the weighted sum of the specified control points,
+    # using the specified weights. This method requires that there are four
+    # weights and four control points.    
+    def weight(w)
+      OpenStruct.new({
+      :x=> w[0] * p0.left + w[1] * p1.left + w[2] * p2.left + w[3] * p3.left,
+      :y=> w[0] * p0.top  + w[1] * p1.top  + w[2] * p2.top  + w[3] * p3.top
+      })
+    end
+    def convert
+      b1 = weight(basis[1])
+      b2 = weight(basis[2])
+      b3 = weight(basis[3])
+      "C#{b1.x},#{b1.y},#{b2.x},#{b2.y },#{b3.x},#{b3.y}"
+    end
+    def to_s
+      convert
+    end
+    def segment
+      b0 = weight(basis[0])
+      b1 = weight(basis[1])
+      b2 = weight(basis[2])
+      b3 = weight(basis[3])
+      "M#{b0.x},#{b0.y}C#{b1.x},#{b1.y},#{b2.x},#{b2.y},#{b3.x},#{b3.y}"
+    end
+  end
+  # Converts the specified b-spline curve segment to a bezier curve
+  # compatible with SVG "C".
+  # * @param p0 the first control point.
+  # * @param p1 the second control point.
+  # * @param p2 the third control point.
+  # * @param p3 the fourth control point.
+  def self.path_basis(p0,p1,p2,p3)
+    PathBasis.new(p0,p1,p2,p3)
+  end
+  
+
+  # Interpolates the given points using the basis spline interpolation.
+  # Returns an SVG path without the leading M instruction to allow path
+  # appending.
+  
+  def self.curve_basis(points) 
+    return "" if (points.size <= 2)
+    path = ""
+    p0 = points[0]
+    p1 = p0
+    p2 = p0
+    p3 = points[1]
+    
+    path += self.path_basis(p0, p1, p2, p3).to_s
+    2.upto(points.size-1) {|i|
+      p0 = p1
+      p1 = p2
+      p2 = p3
+      p3 = points[i]
+      path += self.path_basis(p0, p1, p2, p3).to_s
+    }
+    #  Cycle through to get the last point.
+    path += self.path_basis(p1, p2, p3, p3).to_s
+    path += self.path_basis(p2, p3, p3, p3).to_s
+    path;
+  end
+
+  # Interpolates the given points using the basis spline interpolation.
+  # If points.length == tangents.length then a regular Hermite interpolation is
+  # performed, if points.length == tangents.length + 2 then the first and last
+  # segments are filled in with cubic bazier segments.  Returns an array of path
+  # strings.
+  
+  def self.curve_basis_segments(points) 
+    return "" if (points.size <= 2)
+    paths = []
+    p0 = points[0]
+    p1 = p0
+    p2 = p0
+    p3 = points[1]
+    firstPath = self.path_basis(p0, p1, p2, p3).segment
+    p0 = p1;
+    p1 = p2;
+    p2 = p3;
+    p3 = points[2];
+    paths.push(firstPath + self.path_basis(p0, p1, p2, p3).to_s) # merge first & second path
+    3.upto(points.size-1) {|i|
+      p0 = p1;
+      p1 = p2;
+      p2 = p3;
+      p3 = points[i];
+      paths.push(path_basis(p0, p1, p2, p3).segment);
+    }
+    
+    # merge last & second-to-last path
+    paths.push(path_basis(p1, p2, p3, p3).segment + path_basis(p2, p3, p3, p3).to_s)
+    paths
+  end
+
+  # Interpolates the given points with respective tangents using the cubic
+  # Hermite spline interpolation. If points.length == tangents.length then a regular
+  # Hermite interpolation is performed, if points.length == tangents.length + 2 then
+  # the first and last segments are filled in with cubic bazier segments.
+  # Returns an SVG path without the leading M instruction to allow path appending.
+  #
+  # * @param points the array of points.
+  # * @param tangents the array of tangent vectors.
+  #/
+  
+  def self.curve_hermite(points, tangents)
+    return "" if (tangents.size < 1 or (points.size != tangents.size and points.size != tangents.size + 2)) 
+    quad = points.size != tangents.size
+    path = ""
+    p0 = points[0]
+    p = points[1]
+    t0 = tangents[0]
+    t = t0
+    pi = 1
+
+    if (quad) 
+        path += "Q#{(p.left - t0.x * 2 / 3)},#{(p.top - t0.y * 2 / 3)},#{p.left},#{p.top}"
+        p0 = points[1];
+        pi = 2;
+    end
+
+    if (tangents.length > 1) 
+      t = tangents[1]
+      p = points[pi]
+      pi+=1
+      path += "C#{(p0.left + t0.x)},#{(p0.top + t0.y) },#{(p.left - t.x) },#{(p.top - t.y)},#{p.left},#{p.top}"
+      
+      2.upto(tangents.size-1) {|i|
+        p = points[pi];
+        t = tangents[i];
+        path += "S#{(p.left - t.x)},#{(p.top - t.y)},#{p.left},#{p.top}"
+        pi+=1
+      }
+    end
+
+    if (quad) 
+    lp = points[pi];
+    path += "Q#{(p.left + t.x * 2 / 3)},#{(p.top + t.y * 2 / 3)},#{lp.left},#{lp.top}"
+    end
+
+    path;
+  end
+  # Interpolates the given points with respective tangents using the
+  # cubic Hermite spline interpolation. Returns an array of path strings.
+  #
+  # * @param points the array of points.
+  # * @param tangents the array of tangent vectors.
+  def self.curve_hermite_segments(points, tangents)
+    return [] if (tangents.size < 1 or  (points.size != tangents.size and points.size != tangents.size + 2)) 
+    quad = points.size != tangents.size
+    paths = []
+    p0 = points[0]
+    p = p0
+    t0 = tangents[0]
+    t = t0
+    pi = 1
+    
+    if (quad) 
+    p = points[1]
+    paths.push("M#{p0.left},#{p0.top }Q#{(p.left - t.x * 2 / 3.0 )},#{(p.top - t.y * 2 / 3)},#{p.left},#{p.top}")
+    pi = 2
+    end
+    
+    1.upto(tangents.size-1) {|i|
+    p0 = p;
+    t0 = t;
+    p = points[pi]
+    t = tangents[i]
+    paths.push("M#{p0.left },#{p0.top
+      }C#{(p0.left + t0.x) },#{(p0.top + t0.y)
+      },#{(p.left - t.x) },#{(p.top - t.y)
+      },#{p.left },#{p.top}")
+    pi+=1
+    }
+    
+    if (quad) 
+    lp = points[pi];
+    paths.push("M#{p.left },#{p.top
+        }Q#{(p.left + t.x * 2 / 3) },#{(p.top + t.y * 2 / 3) },#{lp.left },#{lp.top}")
+    end
+    
+    paths
+  end
+
+  # Computes the tangents for the given points needed for cardinal
+  # spline interpolation. Returns an array of tangent vectors. Note: that for n
+  # points only the n-2 well defined tangents are returned.
+  #
+  # * @param points the array of points.
+  # * @param tension the tension of hte cardinal spline.
+  def self.cardinal_tangents(points, tension) 
+    tangents = []
+    a = (1 - tension) / 2.0
+    p0 = points[0]
+    p1 = points[1]
+    p2 = points[2]
+    3.upto(points.size-1) {|i|
+      tangents.push(OpenStruct.new({:x=> a * (p2.left - p0.left), :y=> a * (p2.top - p0.top)}))
+      p0 = p1;
+      p1 = p2;
+      p2 = points[i];
+    }
+  
+    tangents.push(OpenStruct.new({:x=> a * (p2.left - p0.left), :y=> a * (p2.top - p0.top)}))
+    return tangents;
+  end
+
+  
+  # Interpolates the given points using cardinal spline interpolation.
+  # Returns an SVG path without the leading M instruction to allow path
+  # appending.
+  #
+  # * @param points the array of points.
+  # * @param tension the tension of hte cardinal spline.
+  def self.curve_cardinal(points, tension)
+    return "" if (points.size <= 2) 
+    self.curve_hermite(points, self.cardinal_tangents(points, tension))
+  end
+  # Interpolates the given points using cardinal spline interpolation.
+  # Returns an array of path strings.
+  #
+  # @param points the array of points.
+  # @param tension the tension of hte cardinal spline.
+  def self.curve_cardinal_segments(points, tension) 
+    return "" if (points.size <= 2) 
+    self.curve_hermite_segments(points, self.cardinal_tangents(points, tension))
+  end
+
+  # Interpolates the given points using Fritsch-Carlson Monotone cubic
+  # Hermite interpolation. Returns an array of tangent vectors.
+  #
+  # *@param points the array of points.
+  def self.monotone_tangents(points) 
+    tangents = []
+    d = []
+    m = []
+    dx = []
+    #k=0
+    
+    #/* Compute the slopes of the secant lines between successive points. */
+    
+    
+    0.upto(points.size-2) do |k| 
+    
+#    while(k < points.size-1) do 
+      d[k] = (points[k+1].top - points[k].top) / (points[k+1].left - points[k].left).to_f
+      k+=1
+    end
+    
+    #/* Initialize the tangents at every point as the average of the secants. */
+    m[0] = d[0]
+    dx[0] = points[1].left - points[0].left
+    
+    
+    1.upto(points.size-2) {|k|
+      m[k] = (d[k-1]+d[k]) / 2.0
+      dx[k] = (points[k+1].left - points[k-1].left) / 2.0
+    }
+    
+    k=points.size-1
+    
+    m[k] = d[k-1];
+    dx[k] = (points[k].left - points[k-1].left);
+    
+    # /* Step 3. Very important, step 3. Yep. Wouldn't miss it. */
+    (points.size-1).times {|kk|
+      if d[kk] == 0 
+        m[ kk ] = 0;
+        m[kk + 1] = 0;
+      end
+    }
+    
+    # /* Step 4 + 5. Out of 5 or more steps. */
+    
+    
+    (points.size-1).times {|kk|
+      next if ((m[kk].abs < 1e-5) or (m[kk+1].abs < 1e-5))
+      akk = m[kk] / d[kk].to_f
+      bkk = m[kk + 1] / d[kk].to_f
+      s = akk * akk + bkk * bkk; # monotone constant (?)
+      if (s > 9) 
+        tkk = 3.0 / Math.sqrt(s)
+        m[kk] = tkk * akk * d[kk]
+        m[kk + 1] = tkk * bkk * d[kk]
+      end
+    }
+    len=nil;
+    points.size.times {|i|
+      len = 1 + m[i] * m[i]; #// pv.vector(1, m[i]).norm().times(dx[i]/3)
+      tangents.push(OpenStruct.new({:x=> dx[i] / 3.0 / len, :y=> m[i] * dx[i] / 3.0 / len}))
+    }
+    
+    tangents;
+  end
+
+  # Interpolates the given points using Fritsch-Carlson Monotone cubic
+  # Hermite interpolation. Returns an SVG path without the leading M instruction
+  # to allow path appending.
+  #
+  # * @param points the array of points.
+  def self.curve_monotone(points) 
+     return "" if (points.length <= 2)
+     return self.curve_hermite(points, self.monotone_tangents(points))
+  end
+
+  # Interpolates the given points using Fritsch-Carlson Monotone cubic
+  # Hermite interpolation.
+  # Returns an array of path strings.
+  #
+  # * @param points the array of points.
+  #/
+  def self.curve_monotone_segments(points) 
+    return "" if (points.size <= 2)
+     self.curve_hermite_segments(points, self.monotone_tangents(points))
+  end
+
+end
diff --git a/lib/rubyvis/scene/svg_dot.rb b/lib/rubyvis/scene/svg_dot.rb
new file mode 100644
index 0000000..82a358d
--- /dev/null
+++ b/lib/rubyvis/scene/svg_dot.rb
@@ -0,0 +1,68 @@
+module Rubyvis
+  module SvgScene
+    def self.dot(scenes)
+      #e = scenes._g.elements[1]
+      e=scenes._g.get_element(1)
+      scenes.each_with_index {|s,i|
+      s = scenes[i];
+      
+      # visible */
+      next if !s.visible
+      fill = s.fill_style
+      stroke = s.stroke_style
+      next if (fill.opacity==0 and stroke.opacity==0)
+      
+      #/* points */
+      radius = s.shape_radius
+      path = nil
+      case s.shape
+      when 'cross'
+        path = "M#{-radius},#{-radius}L#{radius},#{radius}M#{radius},#{ -radius}L#{ -radius},#{radius}"
+      when "triangle"
+        h = radius
+        w = radius * 1.1547; # // 2 / Math.sqrt(3)
+        path = "M0,#{h}L#{w},#{-h} #{-w},#{-h}Z"
+      when  "diamond"
+        radius=radius* Math::sqrt(2)
+        path = "M0,#{-radius}L#{radius},0 0,#{radius} #{-radius},0Z";
+      when  "square"
+        path = "M#{-radius},#{-radius}L#{radius},#{-radius} #{radius},#{radius} #{-radius},#{radius}Z"
+      when  "tick"
+        path = "M0,0L0,#{-s.shapeSize}"
+      when  "bar"
+        path = "M0,#{s.shape_size / 2.0}L0,#{-(s.shapeSize / 2.0)}"
+
+      end
+      
+      #/* Use <circle> for circles, <path> for everything else. */
+      svg = {
+      "shape-rendering"=> s.antialias ? nil : "crispEdges",
+      "pointer-events"=> s.events,
+      "cursor"=> s.cursor,
+      "fill"=> fill.color,
+      "fill-opacity"=> (fill.opacity==0) ? nil : fill.opacity,
+      "stroke"=> stroke.color,
+      "stroke-opacity"=> (stroke.opacity==0) ? nil : stroke.opacity,
+      "stroke-width"=> (stroke.opacity!=0) ? s.line_width / self.scale : nil
+      }
+      
+      if (path) 
+          svg["transform"] = "translate(#{s.left},#{s.top})"
+          if (s.shape_angle) 
+            svg["transform"] += " rotate(#{180 * s.shape_angle / Math.PI})";
+          end
+        svg["d"] = path
+        e = self.expect(e, "path", svg);
+      else 
+        svg["cx"] = s.left;
+        svg["cy"] = s.top;
+        svg["r"] = radius;
+        e = self.expect(e, "circle", svg);
+      end
+      e = self.append(e, scenes, i);
+      }
+      return e
+    end
+  end
+end
+
diff --git a/lib/rubyvis/scene/svg_image.rb b/lib/rubyvis/scene/svg_image.rb
new file mode 100644
index 0000000..a04370c
--- /dev/null
+++ b/lib/rubyvis/scene/svg_image.rb
@@ -0,0 +1,30 @@
+module Rubyvis
+  module SvgScene
+    def self.image(scenes)
+      #e=scenes._g.elements[1]
+      e=scenes._g.get_element(1)
+      scenes.each_with_index do |s,i|
+        next unless s.visible
+        e=self.fill(e,scenes,i)
+        if s.image
+          raise "Not implemented yet"
+        else
+          e = self.expect(e, "image", {
+          "preserveAspectRatio"=> "none",
+          "cursor"=> s.cursor,
+          "x"=> s.left,
+          "y"=> s.top,
+          "width"=> s.width,
+          "height"=> s.height,
+          })
+          e.set_attributes("xlink:href"=>s.url);
+        end
+        e = self.append(e, scenes, i);
+        
+        #/* stroke */
+        e = self.stroke(e, scenes, i);
+      end
+      e
+    end
+  end
+end
diff --git a/lib/rubyvis/scene/svg_label.rb b/lib/rubyvis/scene/svg_label.rb
new file mode 100644
index 0000000..46bc1ea
--- /dev/null
+++ b/lib/rubyvis/scene/svg_label.rb
@@ -0,0 +1,55 @@
+module Rubyvis
+  module SvgScene
+    def self.label(scenes)
+      #e=scenes._g.elements[1]
+      e=scenes._g.get_element(1)
+      scenes.each_with_index do |s,i|
+        next unless s.visible
+        fill=s.text_style
+        next if(fill.opacity==0 or s.text.nil?)
+        x=0
+        y=0
+        dy=0
+        anchor='start'
+        case s.text_baseline
+          when 'middle'
+            dy=".35em"
+          when "top"
+            dy = ".71em"
+            y = s.text_margin
+          when "bottom"
+            y = "-" + s.text_margin.to_s
+        end
+        
+        case s.text_align
+          when 'right'
+            anchor = "end"
+            x = "-" + s.text_margin.to_s
+          when "center"
+            anchor = "middle"
+          when "left"
+            x = s.text_margin
+        end
+        e=SvgScene.expect(e,'text', {
+          "pointer-events"=> s.events,
+          "cursor"=> s.cursor,
+          "x"=> x,
+          "y"=> y,
+          "dy"=> dy,
+          "transform"=> "translate(#{s.left},#{s.top})" + (s.text_angle!=0 ? " rotate(" + (180 * s.text_angle / Math::PI).to_s + ")" : "") + (self.scale != 1 ? " scale(" + 1 / self.scale + ")" : ""),
+          "fill"=> fill.color,
+          "fill-opacity"=> fill.opacity==0 ? nil : fill.opacity,
+          "text-anchor"=> anchor
+        }, {
+        "font"=> s.font, "text-shadow"=> s.text_shadow, "text-decoration"=> s.text_decoration})
+        
+        e.text=s.text.frozen? ? s.text.dup : s.text
+
+
+        e=SvgScene.append(e,scenes,i)
+
+      end
+      e
+    end
+  end
+end
diff --git a/lib/rubyvis/scene/svg_line.rb b/lib/rubyvis/scene/svg_line.rb
new file mode 100644
index 0000000..08bb72c
--- /dev/null
+++ b/lib/rubyvis/scene/svg_line.rb
@@ -0,0 +1,189 @@
+module Rubyvis
+  module SvgScene
+    def self.line(scenes)
+      #e=scenes._g.elements[1]
+      e=scenes._g.get_element(1)
+      return e if (scenes.size < 2)
+      s = scenes[0]
+      # segmented */
+      return self.line_segment(scenes) if (s.segmented)
+
+      #/* visible */
+      return e if (!s.visible)
+      fill = s.fill_style
+      stroke = s.stroke_style
+
+      return e if (fill.opacity==0.0 and  stroke.opacity==0.0)
+      #/* points */
+
+      d = "M#{s.left},#{s.top}"
+
+      if (scenes.size > 2 and (['basis', 'cardinal', 'monotone'].include? s.interpolate))
+        case (s.interpolate)
+          when "basis"
+            d = d+ curve_basis(scenes)
+          when "cardinal"
+            d = d+curve_cardinal(scenes, s.tension)
+          when "monotone"
+            d = d+curve_monotone(scenes)
+        end
+
+      else
+        (1...scenes.size).each {|i|
+          d+= path_segment(scenes[i-1],scenes[i])
+        }
+      end
+
+      e = SvgScene.expect(e, "path", {
+        "shape-rendering"=> s.antialias ? nil : "crispEdges",
+        "pointer-events"=> s.events,
+        "cursor"=> s.cursor,
+        "d"=> d,
+        "fill"=> fill.color,
+        "fill-opacity"=> (fill.opacity==0.0) ? nil : fill.opacity,
+        "stroke"=> stroke.color,
+        "stroke-opacity"=> (stroke.opacity==0.0) ? nil : stroke.opacity,
+        "stroke-width"=> (stroke.opacity>0) ? s.line_width / self.scale : nil,
+        "stroke-linejoin"=> s.line_join
+      });
+      return SvgScene.append(e, scenes, 0);
+    end
+
+    def self.line_segment(scenes)
+
+      #e=scenes._g.elements[1]
+      e=scenes._g.get_element(1)
+      s = scenes[0];
+      paths=nil
+      case s.interpolate
+        when "basis"
+          paths = curve_basis_segments(scenes)
+        when "cardinal"
+          paths=curve_cardinal_segments(scenes, s.tension)
+        when "monotone"
+          paths = curve_monotone_segments(scenes)
+      end
+
+      (0...(scenes.size-1)).each {|i|
+
+        s1 = scenes[i]
+        s2 = scenes[i + 1];
+        #p "#{s1.top} #{s1.left} #{s1.line_width} #{s1.interpolate} #{s1.line_join}"
+        # visible 
+        next if (!s1.visible or !s2.visible)
+
+        stroke = s1.stroke_style
+        fill = Rubyvis::Color.transparent
+
+        next if stroke.opacity==0.0
+
+        # interpolate
+        d=nil
+        if ((s1.interpolate == "linear") and (s1.line_join == "miter"))
+          fill = stroke
+          stroke = Rubyvis::Color.transparent
+          s0=((i-1) < 0) ? nil : scenes[i-1]
+          s3=((i+2) >= scenes.size) ? nil : scenes[i+2]
+          
+          d = path_join(s0, s1, s2, s3)
+        elsif(paths)
+          d = paths[i]
+        else
+          d = "M#{s1.left},#{s1.top}#{path_segment(s1, s2)}"
+        end
+
+        e = SvgScene.expect(e, "path", {
+          "shape-rendering"=> s1.antialias ? nil : "crispEdges",
+          "pointer-events"=> s1.events,
+          "cursor"=> s1.cursor,
+          "d"=> d,
+          "fill"=> fill.color,
+          "fill-opacity"=> (fill.opacity==0.0) ? nil : fill.opacity,
+          "stroke"=> stroke.color,
+          "stroke-opacity"=> (stroke.opacity==0.0) ? nil : stroke.opacity,
+          "stroke-width"=> stroke.opacity>0 ? s1.line_width / self.scale : nil,
+          "stroke-linejoin"=> s1.line_join
+        });
+        e = SvgScene.append(e, scenes, i);
+      }
+      e
+    end
+
+    # Returns the path segment for the specified points. */
+
+    def self.path_segment(s1, s2) 
+      l = 1; # sweep-flag
+      l = 0 if s1.interpolate=='polar-reverse'
+      
+      if s1.interpolate=='polar' or s1.interpolate=='polar-reverse'
+        dx = s2.left - s1.left
+        dy = s2.top - s1.top
+        e = 1 - s1.eccentricity
+        r = Math.sqrt(dx * dx + dy * dy) / (2 * e)
+        if !((e<=0) or (e>1))
+          return "A#{r},#{r} 0 0,#{l} #{s2.left},#{s2.top}"
+        end
+      end
+      
+      if s1.interpolate=="step-before"
+        return "V#{s2.top}H#{s2.left}"
+      elsif s1.interpolate=="step-after"
+        return "H#{s2.left}V#{s2.top}"
+      end
+      
+      return "L#{s2.left},#{s2.top}"
+    end
+
+    #/** @private Line-line intersection, per Akenine-Moller 16.16.1. */
+    def self.line_intersect(o1, d1, o2, d2)
+      return o1.plus(d1.times(o2.minus(o1).dot(d2.perp()) / d1.dot(d2.perp())));
+    end
+
+    #/** @private Returns the miter join path for the specified points. */
+    def self.path_join(s0, s1, s2, s3)
+      #
+      # P1-P2 is the current line segment. V is a vector that is perpendicular to
+      # the line segment, and has length lineWidth / 2. ABCD forms the initial
+      # bounding box of the line segment (i.e., the line segment if we were to do
+      # no joins).
+      #
+
+      p1 = Rubyvis.vector(s1.left, s1.top)
+
+      p2 = Rubyvis.vector(s2.left, s2.top)
+
+      _p = p2.minus(p1)
+
+      v = _p.perp().norm()
+      
+      w = v.times(s1.line_width / (2.0 * self.scale))
+
+      a = p1.plus(w)
+      b = p2.plus(w)
+      c = p2.minus(w)
+      d = p1.minus(w)
+      #/*
+      # * Start join. P0 is the previous line segment's start point. We define the
+      # * cutting plane as the average of the vector perpendicular to P0-P1, and
+      # * the vector perpendicular to P1-P2. This insures that the cross-section of
+      # * the line on the cutting plane is equal if the line-width is unchanged.
+      # * Note that we don't implement miter limits, so these can get wild.
+      # */
+      if (s0 and s0.visible)
+        v1 = p1.minus(s0.left, s0.top).perp().norm().plus(v)
+        d = line_intersect(p1, v1, d, _p)
+        a = line_intersect(p1, v1, a, _p)
+      end
+
+      #/* Similarly, for end join. */
+      if (s3 and s3.visible)
+        v2 = Rubyvis.vector(s3.left, s3.top).minus(p2).perp().norm().plus(v);
+        c = line_intersect(p2, v2, c, _p);
+        b = line_intersect(p2, v2, b, _p);
+      end
+
+      d="M#{a.x},#{a.y}L#{b.x},#{b.y} #{c.x},#{c.y} #{d.x},#{d.y}"
+      d
+    end
+  end
+end
diff --git a/lib/rubyvis/scene/svg_panel.rb b/lib/rubyvis/scene/svg_panel.rb
new file mode 100644
index 0000000..6686e2a
--- /dev/null
+++ b/lib/rubyvis/scene/svg_panel.rb
@@ -0,0 +1,151 @@
+module Rubyvis
+  module SvgScene
+    def self.panel(scenes)
+      puts " -> panel: #{scenes.inspect}" if $DEBUG
+      g=scenes._g
+      #e=(g.nil?) ? nil : g.elements[1]
+      e=(g.nil?) ? nil : g.get_element(1) 
+      if g
+        #e=g.elements[1]
+        e=g.get_element(1)
+      end
+      scenes.each_with_index do |s,i|
+        next unless s.visible
+
+        if(!scenes.parent)
+          if g and g.parent!=s.canvas
+            #g=s.canvas.elements[1]
+            g=s.canvas.get_element(1)
+            #e=(@g.nil?) ? nil : @g.elements[1]
+            e=(@g.nil?) ? nil : @g.get_element(1)
+          end
+          if(!g)
+            g=s.canvas.add_element(self.create('svg'))
+            g.set_attributes(
+              {
+                'font-size'=>"10px",
+                'font-family'=>'sans-serif',
+                'fill'=>'none',
+                'stroke'=>'none',
+                'stroke-width'=>1.5
+              }
+            )
+            e=g.get_element(1)
+            # g.attributes["font-size"]="10px"
+            # g.attributes["font-family"]="sans-serif"
+            # g.attributes["fill"]="none"
+            # g.attributes["stroke"]="none"
+            # g.attributes["stroke-width"]=1.5
+            # e=g.elements[1]
+          end
+          scenes._g=g
+          #p s
+          g.set_attributes({
+              'width'=>s.width+s.left+s.right,
+              'height'=>s.height+s.top+s.bottom
+          })
+          #g.attributes['width']=s.width+s.left+s.right
+          #g.attributes['height']=s.height+s.top+s.bottom
+        end
+        if s.overflow=='hidden'
+          id=Rubyvis.id.to_s(36)
+          c=self.expect(e,'g',{'clip-path'=>'url(#'+id+')'});
+          g.add_element(c) if(!c.parent)
+          scenes._g=g=c
+          #e=c.elements[1]
+          e=c.get_element(1)
+          e=self.expect(e,'clipPath',{'id'=>id})
+          #r=(e.elements[1]) ? e.elements[1] : e.add_element(self.create('rect'))
+          r=(e.get_element(1)) ? e.get_element(1) : e.add_element(self.create('rect'))
+          r.set_attributes({
+              'x'=>s.left,
+              'y'=>s.top,
+              'width'=>s.width,
+              'height'=>s.height
+          })
+          #r.attributes['x']=s.left
+          #r.attributes['y']=s.top
+          #r.attributes['width']=s.width
+          #r.attributes['height']=s.height
+          g.add_element(e) if !e.parent
+          e=e.next_sibling_node
+
+        end
+        # fill
+        e=self.fill(e,scenes, i)
+        # transform
+        k=self.scale
+        t=s.transform
+        x=s.left+t.x
+        y=s.top+t.y
+        SvgScene.scale=SvgScene.scale*t.k
+        # children
+        s.children.each_with_index {|child, i2|
+          child._g=e=SvgScene.expect(e, "g", {
+            "transform"=> "translate(" + x.to_s + "," + y.to_s + ")" + (t.k != 1 ? " scale(" + t.k.to_s + ")" : "")
+          })
+          SvgScene.update_all(child)
+          g.add_element(e) if(!e.parent)
+          e=e.next_sibling_node
+        }
+        # transform (pop)
+        SvgScene.scale=k
+        # stroke
+        e=SvgScene.stroke(e,scenes,i)
+        # clip
+        if (s.overflow=='hidden')
+          scenes._g=g=c.parent
+          e=c.next_sibling_node
+        end
+      end
+      return e
+      
+    end
+
+
+
+    def self.fill(e,scenes,i)
+      s=scenes[i]
+      fill=s.fill_style
+      if(fill.opacity>0 or s.events=='all')
+        e=SvgScene.expect(e,'rect', {
+          "shape-rendering"=> s.antialias ? nil : "crispEdges",
+          "pointer-events"=> s.events,
+          "cursor"=> s.cursor,
+          "x"=> s.left,
+          "y"=> s.top,
+          "width"=> s.width,
+          "height"=> s.height,
+          "fill"=> fill.color,
+          "fill-opacity"=> fill.opacity,
+          "stroke"=> nil
+        })
+        e=SvgScene.append(e,scenes, i)
+      end
+      e
+    end
+
+
+    def self.stroke(e, scenes, i)
+      s = scenes[i]
+      stroke = s.stroke_style
+      if (stroke.opacity>0 or s.events == "all")
+        e = self.expect(e, "rect", {
+          "shape-rendering"=> s.antialias ? nil : "crispEdges",
+          "pointer-events"=> s.events == "all" ? "stroke" : s.events,
+          "cursor"=> s.cursor,
+          "x"=> s.left,
+          "y"=> s.top,
+          "width"=> [1E-10, s.width].max,
+          "height"=>[1E-10, s.height].max,
+          "fill"=>"none",
+          "stroke"=> stroke.color,
+          "stroke-opacity"=> stroke.opacity,
+          "stroke-width"=> s.line_width / self.scale.to_f
+        });
+        e = self.append(e, scenes, i);
+      end
+      return e
+    end
+  end
+end
diff --git a/lib/rubyvis/scene/svg_rule.rb b/lib/rubyvis/scene/svg_rule.rb
new file mode 100644
index 0000000..7e136a9
--- /dev/null
+++ b/lib/rubyvis/scene/svg_rule.rb
@@ -0,0 +1,29 @@
+module Rubyvis
+  module SvgScene
+    def self.rule(scenes)
+      #e=scenes._g.elements[1]
+      e=scenes._g.get_element(1)
+      scenes.each_with_index do |s,i|
+        next unless s.visible
+        stroke=s.stroke_style
+        next if(stroke.opacity==0.0)
+        e=SvgScene.expect(e,'line', {
+          "shape-rendering"=> s.antialias ? nil : "crispEdges",
+          "pointer-events"=> s.events,
+          "cursor"=> s.cursor,
+          "x1"=> s.left,
+          "y1"=> s.top,
+          'x2'=> s.left+s.width,
+          'y2'=>s.top+s.height,
+          "stroke"=> stroke.color,
+          "stroke-opacity"=> stroke.opacity,
+          "stroke-width"=> s.line_width / self.scale
+        })
+
+        e=SvgScene.append(e,scenes,i)
+
+      end
+      e
+    end
+  end
+end
diff --git a/lib/rubyvis/scene/svg_scene.rb b/lib/rubyvis/scene/svg_scene.rb
new file mode 100644
index 0000000..47e89f2
--- /dev/null
+++ b/lib/rubyvis/scene/svg_scene.rb
@@ -0,0 +1,217 @@
+require 'rubyvis/scene/svg_panel'
+require 'rubyvis/scene/svg_bar'
+require 'rubyvis/scene/svg_rule'
+require 'rubyvis/scene/svg_label'
+require 'rubyvis/scene/svg_line'
+require 'rubyvis/scene/svg_dot'
+require 'rubyvis/scene/svg_area'
+require 'rubyvis/scene/svg_wedge'
+require 'rubyvis/scene/svg_image'
+require 'rubyvis/scene/svg_curve'
+
+class REXML::Element #:nodoc:
+  attr_accessor :_scene
+  # 1 number based
+  def get_element(i)
+    elements[i]
+  end
+  def set_attributes(h)
+    h.each do |k,v|
+      attributes[k]=v
+    end
+  end
+  #private :attributes
+  #private :elements
+end
+
+module Nokogiri
+  module XML
+    class Node
+      attr_accessor :_scene
+      def add_element(c)
+        add_child(c)
+      end
+  
+      def set_attributes(h)
+        h.each do |k,v|
+          set_attribute(k,v.to_s)
+        end
+      end
+      def get_element(i)
+        elements.empty? ? nil : elements[i-1]
+      end
+      #private :elements
+      #private :attributes
+      def next_sibling_node
+        next_sibling
+      end
+      def delete_attribute(name)
+        remove_attribute(name)
+      end
+      def text
+        content
+      end
+      def text=(v)
+        self.content=v
+      end
+    end
+  end
+end
+
+module Rubyvis
+  module SvgScene # :nodoc:
+    #include REXML
+    def self.svg
+      "http://www.w3.org/2000/svg"
+    end;
+    def self.xmlns
+      "http://www.w3.org/2000/xmlns"
+    end
+    def self.xlink
+      "http://www.w3.org/1999/xlink"
+    end
+    def self.xhtml
+      "http://www.w3.org/1999/xhtml"
+    end
+    @scale=1
+    def self.scale
+      @scale
+    end
+    def self.scale=(v)
+      @scale=v
+    end
+    IMPLICIT={:svg=>{
+        "shape-rendering"=> "auto",
+        "pointer-events"=> "painted",
+        "x"=> 0,
+        "y"=> 0,
+        "dy"=> 0,
+        "text-anchor"=> "start",
+        "transform"=> "translate(0,0)",
+        #"fill"=> "none",
+        "fill-opacity"=> 1,
+        "stroke"=> "none",
+        "stroke-opacity"=> 1,
+        "stroke-width"=> 1.5,
+        "stroke-linejoin"=> "miter"
+      },:css=>{"font"=>"10px sans-serif"}
+    }
+    
+    def self.update_all(scenes)
+      puts "update_all: #{scenes.inspect}" if $DEBUG
+      if (scenes.size>0 and scenes[0].reverse and scenes.type!='line' and scenes.type!='area')
+        scenes=scenes.reverse
+      end
+      self.remove_siblings(self.send(scenes.type, scenes))
+    end
+    def self.remove_siblings(e)
+      while(e)
+        n=e.next_sibling_node
+        e.remove
+        e=n
+      end
+    end
+    def self.create(type)
+      if Rubyvis.xml_engine==:nokogiri
+        el=Rubyvis.nokogiri_document.create_element("#{type}")
+        if type=='svg'
+          el.add_namespace(nil, self.svg)
+          el.add_namespace('xlink', self.xlink)
+        end
+      else
+        el=REXML::Element.new "#{type}"
+        if type=='svg'
+          el.add_namespace(self.svg)
+          #el.add_namespace("xmlns:xmlns", self.xmlns)
+          el.add_namespace("xmlns:xlink", self.xlink)
+        end
+      end
+      el
+    end
+
+    def self.append(e,scenes,index)
+      e._scene=OpenStruct.new({:scenes=>scenes, :index=>index})
+      e=self.title(e, scenes[index])
+      if(!e.parent)
+        scenes._g.add_element(e)
+      end
+      e.next_sibling_node
+    end
+    
+    # Applies a title tooltip to the specified element <tt>e</tt>, using the
+    # <tt>title</tt> property of the specified scene node <tt>s</tt>. Note that
+    # this implementation does not create an SVG <tt>title</tt> element as a child
+    # of <tt>e</tt>; although this is the recommended standard, it is only
+    # supported in Opera. Instead, an anchor element is created around the element
+    # <tt>e</tt>, and the <tt>xlink:title</tt> attribute is set accordingly.
+    #
+    # @param e an SVG element.
+    # @param s a scene node.
+    
+    def self.title(e,s)
+      a = e.parent
+      a=nil if (a and (a.name != "a"))
+      if (s.title) 
+        if (!a) 
+          a = self.create("a")
+          e.parent.replace_child(a, e) if (e.parent)
+          a.add_element(e)
+        end
+        #a.add_attribute('xlink:title',s.title)
+        a.set_attributes('xlink:title' => s.title)
+
+        return a;
+      end
+      a.parent_node.replace_child(e, a) if (a) 
+      e
+    end
+    
+    def self.expect(e, type, attributes, style=nil)
+
+      if (e)
+        #e = e.elements[1] if (e.name == "a")
+        e=e.get_element(1) if (e.name == 'a')
+        if (e.name != type)
+          n = self.create(type);
+          e.parent.replace_child(e, n);
+          e = n
+        end
+      else
+        e = self.create(type)
+      end
+      attributes.each {|name,value|
+        value = nil if (value == IMPLICIT[:svg][name])
+        if (value.nil?)
+          e.delete_attribute(name)
+        else
+          e.set_attributes(name=>value)
+          #e.attributes[name]=value
+        end
+      }
+      
+      if(style)
+        base_style=e.attributes['style']
+        base_style||=""
+        array_styles={}
+        base_style.split(";").each {|v|
+          v=~/\s*(.+)\s*:\s*(.+)/
+          array_styles[$1]=$2
+        }
+        style.each {|name,value|
+          value=nil if value==IMPLICIT[:css][name]
+          if (value.nil?)
+            array_styles.delete(name)
+          else
+            array_styles[name]=value
+          end
+        }
+        if array_styles.size>0
+          #e.attributes["style"]=array_styles.map {|k,v| "#{k}:#{v}"}.join(";")
+          e.set_attributes('style'=> array_styles.map {|k,v| "#{k}:#{v}"}.join(";"))
+        end
+      end
+      e
+    end
+
+  end
+end
diff --git a/lib/rubyvis/scene/svg_wedge.rb b/lib/rubyvis/scene/svg_wedge.rb
new file mode 100644
index 0000000..6c60235
--- /dev/null
+++ b/lib/rubyvis/scene/svg_wedge.rb
@@ -0,0 +1,58 @@
+module Rubyvis
+  module SvgScene
+    def self.wedge(scenes)
+      #e=scenes._g.elements[1]
+      e=scenes._g.get_element(1)
+      scenes.each_with_index do |s,i|
+        next unless s.visible
+        fill=s.fill_style
+        stroke=s.stroke_style
+        next if(fill.opacity==0.0 and stroke.opacity==0.0)
+        # /* points */
+        
+        r1 = s.inner_radius
+        r2 = s.outer_radius
+
+        a = (s.angle).abs
+        _p=nil
+        
+        if (a >= 2 * Math::PI) 
+          if (r1!=0) 
+            _p = "M0,#{r2 }A#{r2},#{r2} 0 1,1 0,#{-r2}A#{r2 },#{r2 } 0 1,1 0,#{r2}M0,#{r1}A#{r1},#{r1} 0 1,1 0,#{-r1}A#{r1},#{r1} 0 1,1 0,#{r1 }Z"
+          else 
+            _p = "M0,#{r2}A#{r2},#{r2} 0 1,1 0,#{-r2}A#{r2},#{r2} 0 1,1 0,#{r2 }Z"
+          end
+        else 
+          sa = [s.start_angle, s.end_angle].min
+          ea = [s.start_angle, s.end_angle].max
+          c1 = Math.cos(sa)
+          c2 = Math.cos(ea)
+          s1 = Math.sin(sa)
+          s2 = Math.sin(ea)
+          if (r1!=0)
+            _p = "M#{r2 * c1},#{r2 * s1}A#{r2},#{r2} 0 #{((a < Math::PI) ? "0" : "1")},1 #{r2 * c2},#{r2 * s2}L#{r1 * c2},#{r1 * s2}A#{r1},#{r1} 0 #{((a < Math::PI) ? "0" : "1")},0 #{r1 * c1},#{r1 * s1}Z"
+          else 
+            _p = "M#{r2 * c1},#{r2 * s1}A#{r2},#{r2} 0 #{((a < Math::PI) ? "0" : "1")},1 #{r2 * c2},#{r2 * s2}L0,0Z"
+          end
+        end
+        
+        e = self.expect(e, "path", {
+          "shape-rendering"=> s.antialias ? nil : "crispEdges",
+          "pointer-events"=> s.events,
+          "cursor"=> s.cursor,
+          "transform"=> "translate(#{s.left},#{s.top})",
+          "d"=> _p,
+          "fill"=> fill.color,
+          "fill-rule"=> "evenodd",
+          "fill-opacity"=>  (fill.opacity==0) ? nil : fill.opacity,
+          "stroke"=> stroke.color,
+          "stroke-opacity"=> (stroke.opacity==0) ? nil : stroke.opacity,
+          "stroke-width"=> stroke.opacity>0 ? s.line_width / self.scale.to_f : nil
+        });
+        e=SvgScene.append(e,scenes,i)
+
+      end
+      e
+    end
+  end
+end
diff --git a/lib/rubyvis/sceneelement.rb b/lib/rubyvis/sceneelement.rb
new file mode 100644
index 0000000..9f56387
--- /dev/null
+++ b/lib/rubyvis/sceneelement.rb
@@ -0,0 +1,54 @@
+module Rubyvis
+  # Scene element
+  # Store information about each scene.
+  # On javascript, is an Array with custom properties.
+  class SceneElement # :nodoc:
+    def initialize
+      @scenes=Array.new
+    end
+    include Enumerable
+    attr_accessor :visible
+    attr_accessor :mark, :type, :child_index, :parent, :parent_index, :target, :defs, :data,  :antialias, :line_width, :fill_style, :overflow, :width, :height, :top, :bottom, :left, :right, :title, :reverse, :stroke_style, :transform, :canvas, :_g, :events, :cursor, :children, :id, :segmented, :interpolate, :tension, :name, :text_baseline, :text_align, :text, :font, :text_angle, :text_style, :text_margin, :text_decoration, :text_shadow, :line_join, :eccentricity, :shape_size, :shape, :sh [...]
+    
+    def []=(v,i)
+      if v.is_a? Numeric
+        @scenes[v]=i
+      elsif self.respond_to?(v.to_s+"=")
+        self.send(v.to_s+"=",i)
+      end
+    end
+    def [](v)
+      if v.is_a? Numeric
+        @scenes[v]
+      elsif v.nil?
+        nil
+      elsif self.respond_to? v
+        self.send(v)
+      end
+    end
+    def each
+      @scenes.each do |v|
+        yield v
+      end
+    end
+    def push(v)
+      @scenes.push(v)
+    end
+    def size
+      @scenes.size
+    end
+    def inspect
+      elements_id=@scenes.map{|e| '<'+ e.object_id.to_s(16)+'>'}.join(", ")
+      "<SE #{object_id.to_s(16)} (#{type}), elements: #{self.size} (#{elements_id}), children: #{children ? children.size : '0'}, data: #{data ? data.to_s: ''}>"
+    end
+    def size=(v)
+      if self.size==v
+        return true
+      elsif self.size<v
+        (v-self.size).times {push(nil)}
+      else
+        self.slice!(0,v)
+      end
+    end
+  end
+end
diff --git a/lib/rubyvis/transform.rb b/lib/rubyvis/transform.rb
new file mode 100644
index 0000000..b1f0785
--- /dev/null
+++ b/lib/rubyvis/transform.rb
@@ -0,0 +1,25 @@
+module Rubyvis
+  def self.Transform
+    Rubyvis::Transform
+  end
+  class Transform
+    attr_accessor :k,:x,:y
+    def initialize
+      @k=1
+      @x=0
+      @y=0
+    end
+    def translate(x,y)
+      v=Transform.new
+      v.k=self.k
+      v.x=self.k*x+self.x
+      v.y=self.k*y+self.y
+      v
+
+    end
+    def self.identity
+      Transform.new
+    end
+  end
+
+end
diff --git a/lib/rubyvis/vector.rb b/lib/rubyvis/vector.rb
new file mode 100644
index 0000000..b495353
--- /dev/null
+++ b/lib/rubyvis/vector.rb
@@ -0,0 +1,104 @@
+module Rubyvis
+  # Returns a {@link pv.Vector} for the specified <i>x</i> and <i>y</i>
+  # coordinate. This is a convenience factory method, equivalent to <tt>new
+  # pv.Vector(x, y)</tt>.
+  #
+  # @see pv.Vector
+  # @param {number} x the <i>x</i> coordinate.
+  # @param {number} y the <i>y</i> coordinate.
+  # @returns {pv.Vector} a vector for the specified coordinates.
+  
+  def self.vector(x,y) 
+    Rubyvis::Vector.new(x,y)
+  end
+  class Vector
+    attr_accessor :x,:y
+    # Constructs a {@link pv.Vector} for the specified <i>x</i> and <i>y</i>
+    # coordinate. This constructor should not be invoked directly; use
+    # {@link pv.vector} instead.
+    #
+    # @class Represents a two-dimensional vector; a 2-tuple <i>&#x27e8;x,
+    # y&#x27e9;</i>. The intent of this class is to simplify vector math. Note that
+    # in performance-sensitive cases it may be more efficient to represent 2D
+    # vectors as simple objects with <tt>x</tt> and <tt>y</tt> attributes, rather
+    # than using instances of this class.
+    #
+    # @param {number} x the <i>x</i> coordinate.
+    # @param {number} y the <i>y</i> coordinate.
+    def initialize(x,y) 
+      @x=x
+      @y=y
+    end
+    def ==(v)
+      @x==v.x and @y==v.y
+    end
+    # Returns a vector perpendicular to this vector: <i>&#x27e8;-y, x&#x27e9;</i>.
+    #
+    # @returns {pv.Vector} a perpendicular vector.
+    #/
+    def perp
+      Rubyvis::Vector.new(- at y, at x)
+    end
+    # Returns a normalized copy of this vector: a vector with the same direction,
+    # but unit length. If this vector has zero length this method returns a copy of
+    # this vector.
+    #
+    # @returns {pv.Vector} a unit vector.
+    def norm 
+      l=length()
+      times(l!=0 ? (1.0 / l) : 1.0)
+    end
+    
+    # Returns the magnitude of this vector, defined as <i>sqrt(x * x + y * y)</i>.
+    #
+    # @returns {number} a length.
+    def length
+      Math.sqrt(@x**2 + @y**2)
+    end
+
+    # Returns a scaled copy of this vector: <i>&#x27e8;x * k, y * k&#x27e9;</i>.
+    # To perform the equivalent divide operation, use <i>1 / k</i>.
+    #
+    # @param {number} k the scale factor.
+    # @returns {pv.Vector} a scaled vector.
+    def times(k)
+      Rubyvis::Vector.new(@x * k, @y * k)
+    end
+    # Returns this vector plus the vector <i>v</i>: <i>&#x27e8;x + v.x, y +
+    # v.y&#x27e9;</i>. If only one argument is specified, it is interpreted as the
+    # vector <i>v</i>.
+    #
+    # @param {number} x the <i>x</i> coordinate to add.
+    # @param {number} y the <i>y</i> coordinate to add.
+    # @returns {pv.Vector} a new vector.
+    def plus(x,y=nil)
+      
+      return (y.nil?) ? Rubyvis::Vector.new(@x + x.x, @y + x.y) : Rubyvis::Vector.new(@x + x, @y + y)
+    end
+    
+    # Returns this vector minus the vector <i>v</i>: <i>&#x27e8;x - v.x, y -
+    # v.y&#x27e9;</i>. If only one argument is specified, it is interpreted as the
+    # vector <i>v</i>.
+    #
+    # @param {number} x the <i>x</i> coordinate to subtract.
+    # @param {number} y the <i>y</i> coordinate to subtract.
+    # @returns {pv.Vector} a new vector.
+    
+    def minus(x,y=nil)
+      
+      return (y.nil?) ? Rubyvis::Vector.new(@x - x.x, @y - x.y) : Rubyvis::Vector.new(@x - x, @y - y)
+    end
+
+    # Returns the dot product of this vector and the vector <i>v</i>: <i>x * v.x +
+    # y * v.y</i>. If only one argument is specified, it is interpreted as the
+    # vector <i>v</i>.
+    #
+    # @param {number} x the <i>x</i> coordinate to dot.
+    # @param {number} y the <i>y</i> coordinate to dot.
+    # @returns {number} a dot product.
+    def dot(x, y=nil) 
+      (y.nil?) ? @x * x.x + @y * x.y : @x * x + @y * y
+    end
+  end
+end
+
diff --git a/metadata.yml b/metadata.yml
new file mode 100644
index 0000000..62f43b9
--- /dev/null
+++ b/metadata.yml
@@ -0,0 +1,461 @@
+--- !ruby/object:Gem::Specification
+name: rubyvis
+version: !ruby/object:Gem::Version
+  version: 0.5.2
+  prerelease: 
+platform: ruby
+authors:
+- Claudio Bustos
+autorequire: 
+bindir: bin
+cert_chain: []
+date: 2012-07-21 00:00:00.000000000 Z
+dependencies:
+- !ruby/object:Gem::Dependency
+  name: rdoc
+  requirement: !ruby/object:Gem::Requirement
+    none: false
+    requirements:
+    - - ~>
+      - !ruby/object:Gem::Version
+        version: '3.10'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    none: false
+    requirements:
+    - - ~>
+      - !ruby/object:Gem::Version
+        version: '3.10'
+- !ruby/object:Gem::Dependency
+  name: coderay
+  requirement: !ruby/object:Gem::Requirement
+    none: false
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    none: false
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: haml
+  requirement: !ruby/object:Gem::Requirement
+    none: false
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    none: false
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: nokogiri
+  requirement: !ruby/object:Gem::Requirement
+    none: false
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    none: false
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: rspec
+  requirement: !ruby/object:Gem::Requirement
+    none: false
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '2.0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    none: false
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '2.0'
+- !ruby/object:Gem::Dependency
+  name: RedCloth
+  requirement: !ruby/object:Gem::Requirement
+    none: false
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    none: false
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: hoe
+  requirement: !ruby/object:Gem::Requirement
+    none: false
+    requirements:
+    - - ~>
+      - !ruby/object:Gem::Version
+        version: '3.0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    none: false
+    requirements:
+    - - ~>
+      - !ruby/object:Gem::Version
+        version: '3.0'
+description: Ruby port of Protovis[http://vis.stanford.edu/protovis/], a Javascript
+  visualization toolkit.
+email:
+- clbustos_at_gmail.com
+executables: []
+extensions: []
+extra_rdoc_files:
+- History.txt
+- Manifest.txt
+- README.txt
+files:
+- History.txt
+- Manifest.txt
+- README.txt
+- Rakefile
+- examples/1_basic/1a_bar_rbp_api.rb
+- examples/1_basic/1b_bar_pv_api.rb
+- examples/1_basic/2_bar_and_rule.rb
+- examples/1_basic/3_grouped_bars.rb
+- examples/1_basic/area_interpolation.rb
+- examples/1_basic/dot.rb
+- examples/1_basic/fixtures/tipsy.gif
+- examples/1_basic/grid.rb
+- examples/1_basic/image.rb
+- examples/1_basic/line.rb
+- examples/1_basic/line_interpolation.rb
+- examples/2_medium/censo_agropecuario/censo_agropecuario_chile_data.rb
+- examples/2_medium/censo_agropecuario/census_treemap.rb
+- examples/2_medium/censo_agropecuario/create_data.rb
+- examples/2_medium/censo_agropecuario/resultset.csv
+- examples/2_medium/horizon.rb
+- examples/2_medium/nested_grid.rb
+- examples/3_pv_conventional/area.rb
+- examples/3_pv_conventional/bar_column_chart.rb
+- examples/3_pv_conventional/grouped_charts.rb
+- examples/3_pv_conventional/line_and_step.rb
+- examples/3_pv_conventional/pie_and_donut.rb
+- examples/3_pv_conventional/scatterplot.rb
+- examples/3_pv_conventional/stacked_charts.rb
+- examples/4_pv_custom/antibiotics/antibiotics_data.rb
+- examples/4_pv_custom/antibiotics/antibiotics_scatter.rb
+- examples/4_pv_custom/antibiotics/antibiotics_wedge.rb
+- examples/4_pv_custom/barley/barley.rb
+- examples/4_pv_custom/barley/barley_data.rb
+- examples/4_pv_custom/cars/cars.rb
+- examples/4_pv_custom/cars/cars_data.rb
+- examples/4_pv_custom/crimea/crimea_data.rb
+- examples/4_pv_custom/crimea/crimea_grouped_bar.rb
+- examples/4_pv_custom/crimea/crimea_line.rb
+- examples/5_pv_hierarchies/bubble_charts.rb
+- examples/5_pv_hierarchies/bubble_charts_matrix.rb
+- examples/5_pv_hierarchies/circle_packing.rb
+- examples/5_pv_hierarchies/dendogram.rb
+- examples/5_pv_hierarchies/icicle.rb
+- examples/5_pv_hierarchies/indent.rb
+- examples/5_pv_hierarchies/node_link_tree.rb
+- examples/5_pv_hierarchies/sunburst.rb
+- examples/5_pv_hierarchies/treemap.rb
+- examples/6_pv_networks/arc.rb
+- examples/6_pv_networks/matrix.rb
+- examples/6_pv_networks/miserables_data.rb
+- lib/rubyvis.rb
+- lib/rubyvis/color/color.rb
+- lib/rubyvis/color/colors.rb
+- lib/rubyvis/dom.rb
+- lib/rubyvis/flatten.rb
+- lib/rubyvis/format.rb
+- lib/rubyvis/format/date.rb
+- lib/rubyvis/format/number.rb
+- lib/rubyvis/histogram.rb
+- lib/rubyvis/internals.rb
+- lib/rubyvis/javascript_behaviour.rb
+- lib/rubyvis/layout.rb
+- lib/rubyvis/layout/arc.rb
+- lib/rubyvis/layout/cluster.rb
+- lib/rubyvis/layout/grid.rb
+- lib/rubyvis/layout/hierarchy.rb
+- lib/rubyvis/layout/horizon.rb
+- lib/rubyvis/layout/indent.rb
+- lib/rubyvis/layout/matrix.rb
+- lib/rubyvis/layout/network.rb
+- lib/rubyvis/layout/pack.rb
+- lib/rubyvis/layout/partition.rb
+- lib/rubyvis/layout/stack.rb
+- lib/rubyvis/layout/tree.rb
+- lib/rubyvis/layout/treemap.rb
+- lib/rubyvis/mark.rb
+- lib/rubyvis/mark/anchor.rb
+- lib/rubyvis/mark/area.rb
+- lib/rubyvis/mark/bar.rb
+- lib/rubyvis/mark/dot.rb
+- lib/rubyvis/mark/image.rb
+- lib/rubyvis/mark/label.rb
+- lib/rubyvis/mark/line.rb
+- lib/rubyvis/mark/panel.rb
+- lib/rubyvis/mark/rule.rb
+- lib/rubyvis/mark/shorcut_methods.rb
+- lib/rubyvis/mark/wedge.rb
+- lib/rubyvis/nest.rb
+- lib/rubyvis/property.rb
+- lib/rubyvis/scale.rb
+- lib/rubyvis/scale/linear.rb
+- lib/rubyvis/scale/log.rb
+- lib/rubyvis/scale/ordinal.rb
+- lib/rubyvis/scale/quantitative.rb
+- lib/rubyvis/scene/svg_area.rb
+- lib/rubyvis/scene/svg_bar.rb
+- lib/rubyvis/scene/svg_curve.rb
+- lib/rubyvis/scene/svg_dot.rb
+- lib/rubyvis/scene/svg_image.rb
+- lib/rubyvis/scene/svg_label.rb
+- lib/rubyvis/scene/svg_line.rb
+- lib/rubyvis/scene/svg_panel.rb
+- lib/rubyvis/scene/svg_rule.rb
+- lib/rubyvis/scene/svg_scene.rb
+- lib/rubyvis/scene/svg_wedge.rb
+- lib/rubyvis/sceneelement.rb
+- lib/rubyvis/transform.rb
+- lib/rubyvis/vector.rb
+- spec/anchor_spec.rb
+- spec/area_spec.rb
+- spec/bar_spec.rb
+- spec/color_spec.rb
+- spec/dom_spec.rb
+- spec/dot_spec.rb
+- spec/fixtures/anchor.html
+- spec/fixtures/anchor.svg
+- spec/fixtures/area-segmented.html
+- spec/fixtures/area_interpolation.html
+- spec/fixtures/area_interpolation.svg
+- spec/fixtures/area_segmented.svg
+- spec/fixtures/dot-anchor.html
+- spec/fixtures/dot_anchor.svg
+- spec/fixtures/image.svg
+- spec/fixtures/layers.js
+- spec/fixtures/layout_arc.svg
+- spec/fixtures/layout_cluster.html
+- spec/fixtures/layout_cluster.svg
+- spec/fixtures/layout_cluster_left_group_2.html
+- spec/fixtures/layout_cluster_left_group_2.svg
+- spec/fixtures/layout_grid.html
+- spec/fixtures/layout_grid.svg
+- spec/fixtures/layout_horizon.svg
+- spec/fixtures/layout_indent.html
+- spec/fixtures/layout_indent.svg
+- spec/fixtures/layout_matrix.svg
+- spec/fixtures/layout_pack.html
+- spec/fixtures/layout_pack.svg
+- spec/fixtures/layout_partition_fill.html
+- spec/fixtures/layout_partition_fill.svg
+- spec/fixtures/layout_tree_orient_left.html
+- spec/fixtures/layout_tree_orient_left.svg
+- spec/fixtures/layout_tree_orient_radial_breadth_20.html
+- spec/fixtures/layout_tree_orient_radial_breadth_20.svg
+- spec/fixtures/layout_tree_orient_top.svg
+- spec/fixtures/layout_treemap.svg
+- spec/fixtures/line_interpolation.html
+- spec/fixtures/line_interpolation.svg
+- spec/fixtures/line_interpolation_segmented.html
+- spec/fixtures/line_interpolation_segmented.svg
+- spec/fixtures/protovis-r3.3.js
+- spec/fixtures/rule-anchor.html
+- spec/fixtures/rule_anchor.svg
+- spec/fixtures/stack-expand.html
+- spec/fixtures/stack-silohouette.html
+- spec/fixtures/stack-wiggle.html
+- spec/fixtures/stack_expand.svg
+- spec/fixtures/stack_silohouette.svg
+- spec/fixtures/stack_wiggle.svg
+- spec/fixtures/svgscene.html
+- spec/fixtures/tipsy.gif
+- spec/fixtures/wedge-anchor.html
+- spec/fixtures/wedge-donut.html
+- spec/fixtures/wedge_anchor.svg
+- spec/fixtures/wedge_donut.svg
+- spec/flatten_spec.rb
+- spec/histogram_spec.rb
+- spec/image_spec.rb
+- spec/internal_spec.rb
+- spec/javascript_behaviour_spec.rb
+- spec/label_spec.rb
+- spec/layout_arc_spec.rb
+- spec/layout_cluster_spec.rb
+- spec/layout_grid_spec.rb
+- spec/layout_horizon_spec.rb
+- spec/layout_indent_spec.rb
+- spec/layout_matrix_spec.rb
+- spec/layout_pack_spec.rb
+- spec/layout_partition_spec.rb
+- spec/layout_stack_spec.rb
+- spec/layout_tree_spec.rb
+- spec/layout_treemap_spec.rb
+- spec/line_spec.rb
+- spec/mark_spec.rb
+- spec/nest_spec.rb
+- spec/panel_spec.rb
+- spec/readme_spec.rb
+- spec/ruby_api_spec.rb
+- spec/rule_spec.rb
+- spec/scale_linear_datetime_spec.rb
+- spec/scale_linear_spec.rb
+- spec/scale_log_spec.rb
+- spec/scale_ordinal_spec.rb
+- spec/scale_spec.rb
+- spec/spec.opts
+- spec/spec_helper.rb
+- spec/vector_spec.rb
+- spec/wedge_spec.rb
+- vendor/protovis/protovis-r3.3.js
+- vendor/protovis/src/behavior/Behavior.js
+- vendor/protovis/src/behavior/Drag.js
+- vendor/protovis/src/behavior/Pan.js
+- vendor/protovis/src/behavior/Point.js
+- vendor/protovis/src/behavior/Resize.js
+- vendor/protovis/src/behavior/Select.js
+- vendor/protovis/src/behavior/Zoom.js
+- vendor/protovis/src/color/Color.js
+- vendor/protovis/src/color/Colors.js
+- vendor/protovis/src/color/Ramp.js
+- vendor/protovis/src/data/Arrays.js
+- vendor/protovis/src/data/Dom.js
+- vendor/protovis/src/data/Flatten.js
+- vendor/protovis/src/data/Histogram.js
+- vendor/protovis/src/data/LinearScale.js
+- vendor/protovis/src/data/LogScale.js
+- vendor/protovis/src/data/Nest.js
+- vendor/protovis/src/data/Numbers.js
+- vendor/protovis/src/data/Objects.js
+- vendor/protovis/src/data/OrdinalScale.js
+- vendor/protovis/src/data/QuantileScale.js
+- vendor/protovis/src/data/QuantitativeScale.js
+- vendor/protovis/src/data/RootScale.js
+- vendor/protovis/src/data/Scale.js
+- vendor/protovis/src/data/Transform.js
+- vendor/protovis/src/data/Tree.js
+- vendor/protovis/src/data/Vector.js
+- vendor/protovis/src/geo/Geo.js
+- vendor/protovis/src/geo/GeoScale.js
+- vendor/protovis/src/geo/LatLng.js
+- vendor/protovis/src/geo/Projection.js
+- vendor/protovis/src/geo/Projections.js
+- vendor/protovis/src/lang/Array.js
+- vendor/protovis/src/lang/init.js
+- vendor/protovis/src/layout/Arc.js
+- vendor/protovis/src/layout/Bullet.js
+- vendor/protovis/src/layout/Cluster.js
+- vendor/protovis/src/layout/Force.js
+- vendor/protovis/src/layout/Grid.js
+- vendor/protovis/src/layout/Hierarchy.js
+- vendor/protovis/src/layout/Horizon.js
+- vendor/protovis/src/layout/Indent.js
+- vendor/protovis/src/layout/Layout.js
+- vendor/protovis/src/layout/Matrix.js
+- vendor/protovis/src/layout/Network.js
+- vendor/protovis/src/layout/Pack.js
+- vendor/protovis/src/layout/Partition.js
+- vendor/protovis/src/layout/Rollup.js
+- vendor/protovis/src/layout/Stack.js
+- vendor/protovis/src/layout/Tree.js
+- vendor/protovis/src/layout/Treemap.js
+- vendor/protovis/src/mark/Anchor.js
+- vendor/protovis/src/mark/Area.js
+- vendor/protovis/src/mark/Bar.js
+- vendor/protovis/src/mark/Dot.js
+- vendor/protovis/src/mark/Ease.js
+- vendor/protovis/src/mark/Image.js
+- vendor/protovis/src/mark/Label.js
+- vendor/protovis/src/mark/Line.js
+- vendor/protovis/src/mark/Mark.js
+- vendor/protovis/src/mark/Panel.js
+- vendor/protovis/src/mark/Rule.js
+- vendor/protovis/src/mark/Transient.js
+- vendor/protovis/src/mark/Transition.js
+- vendor/protovis/src/mark/Wedge.js
+- vendor/protovis/src/physics/BoundConstraint.js
+- vendor/protovis/src/physics/ChargeForce.js
+- vendor/protovis/src/physics/CollisionConstraint.js
+- vendor/protovis/src/physics/Constraint.js
+- vendor/protovis/src/physics/DragForce.js
+- vendor/protovis/src/physics/Force.js
+- vendor/protovis/src/physics/Particle.js
+- vendor/protovis/src/physics/PositionConstraint.js
+- vendor/protovis/src/physics/Quadtree.js
+- vendor/protovis/src/physics/Simulation.js
+- vendor/protovis/src/physics/SpringForce.js
+- vendor/protovis/src/pv-internals.js
+- vendor/protovis/src/pv.js
+- vendor/protovis/src/scene/SvgArea.js
+- vendor/protovis/src/scene/SvgBar.js
+- vendor/protovis/src/scene/SvgCurve.js
+- vendor/protovis/src/scene/SvgDot.js
+- vendor/protovis/src/scene/SvgImage.js
+- vendor/protovis/src/scene/SvgLabel.js
+- vendor/protovis/src/scene/SvgLine.js
+- vendor/protovis/src/scene/SvgPanel.js
+- vendor/protovis/src/scene/SvgRule.js
+- vendor/protovis/src/scene/SvgScene.js
+- vendor/protovis/src/scene/SvgWedge.js
+- vendor/protovis/src/text/DateFormat.js
+- vendor/protovis/src/text/Format.js
+- vendor/protovis/src/text/NumberFormat.js
+- vendor/protovis/src/text/TimeFormat.js
+- web/Rakefile
+- web/build_site.rb
+- web/examples.haml
+- web/index.haml
+- web/style.css
+- .gemtest
+homepage: http://rubyvis.rubyforge.org/
+licenses: []
+post_install_message: 
+rdoc_options:
+- --main
+- README.txt
+require_paths:
+- lib
+required_ruby_version: !ruby/object:Gem::Requirement
+  none: false
+  requirements:
+  - - ! '>='
+    - !ruby/object:Gem::Version
+      version: '0'
+required_rubygems_version: !ruby/object:Gem::Requirement
+  none: false
+  requirements:
+  - - ! '>='
+    - !ruby/object:Gem::Version
+      version: '0'
+requirements: []
+rubyforge_project: rubyvis
+rubygems_version: 1.8.24
+signing_key: 
+specification_version: 3
+summary: Ruby port of Protovis[http://vis.stanford.edu/protovis/], a Javascript visualization
+  toolkit.
+test_files: []
diff --git a/spec/anchor_spec.rb b/spec/anchor_spec.rb
new file mode 100644
index 0000000..6dc44d3
--- /dev/null
+++ b/spec/anchor_spec.rb
@@ -0,0 +1,155 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Anchor do
+  include Rubyvis::GeneralSpec
+  
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :cursor, :data, :events, :id,  :left, :name, :reverse, :right,  :title, :top, :visible].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Anchor.properties.should==props
+  end
+  it "should be initialized with an object which respond to parent" do
+    my_mock=mock('mark')
+    my_mock.should_receive(:parent).with(no_args())
+    Rubyvis.Anchor(my_mock)
+    
+  end
+  describe "inner anchor data should work fine" do
+    before  do
+      w=200
+      h=200
+      data_p1=[]
+      data_p2=[]
+      data_l=[]
+      @expected_l=[]
+      @expected_p2=[]  
+      vis = pv.Panel.new().width(w).height(h)      
+      cell=vis.add(pv.Panel).
+        data([1,2]).top(lambda {|*args| data_p1.push(args); 100}).
+        add(pv.Panel). data(['a','b']).top(lambda {|*args| data_p2.push(args); 100;})
+      
+      cell.anchor('center').add(pv.Bar).top(lambda {|*args| data_l.push args; 1})
+
+      [1,2].each {|a| %w{a b}.each {|b| 
+        @expected_l.push([b,b,a,nil])
+        @expected_p2.push([b,a,nil])
+      }}
+      @expected_p1=[[1,nil],[2,nil]]
+      @data_p1=data_p1
+      @data_p2=data_p2
+      @data_l=data_l
+      vis.render
+      
+    end
+    if(true)
+    it "first loop correct" do
+      @data_p1.should==@expected_p1
+    end
+    it "second loop correct" do
+      @data_p2.should==@expected_p2
+    end
+    end
+    
+    it "label loop correct" do
+      @data_l.should==@expected_l
+    end
+  end
+  
+  it "antibiotics example should render correct data" do
+
+    a1=['a','b','c']
+    a2=[1,2,3]
+    antibiotics=["penicillin", "streptomycin", "neomycin"]
+    adatas=[]
+    s = 180
+    _p = 20
+    vis = pv.Panel.new().
+      height(s * antibiotics.size + _p * (antibiotics.size - 1)).
+      width(s * antibiotics.size + _p * (antibiotics.size - 1)).
+      top(14.5).
+      left(14.5).
+      bottom(44).
+      right(14)
+
+    cell = vis.add(pv.Panel).
+      data(a1).
+      width(s).
+      left(lambda {(s + _p) * index}).
+    add(pv.Panel).
+      data(a2).
+      height(s).
+      top(lambda {(s + _p) * self.index});
+
+    
+    cell.anchor("center").add(pv.Label).text(lambda {|*args| adatas.push args})
+    
+    expected=[]
+    a1.each {|a| a2.each {|b| expected.push([b,b,a,nil])}}
+    vis.render
+    adatas.should==expected
+    
+  end
+  
+  context "Panel-Panel-label assigment" do
+    before do
+      @h=200
+      @w=200
+      @values=["a","b","c"]
+      @vis = Rubyvis.Panel.new.width(@w).height(@h). add(pv.Panel).data(@values). add(pv.Panel).data(@values)
+      @anchor=@vis.anchor('center')
+      @label=@vis.add(pv.Label)
+    end
+    it "should have correct data" do
+      datas=[]
+      @label.text(lambda {|*args| datas.push args})
+      @vis.render
+      expected=[]
+      @values.each {|a| @values.each {|b| expected.push([b,b,a,nil])}}
+      datas.should==expected
+    end
+  end
+  it "should render equal to protovis 'anchor.html' example" do
+      @vis = Rubyvis::Panel.new().
+        width(200).
+        height(200)
+      
+      @vis.add(Rubyvis::Bar).
+        fill_style("#ccc").
+        anchor("top").add(Rubyvis::Label).
+        text("top").
+        target.
+        anchor("bottom").
+        add(pv.Label).
+        text("bottom")
+      @vis.render
+      @pv_out=fixture_svg_read("anchor.svg")
+      @vis.to_svg.should have_same_svg_elements(@pv_out)
+  end
+  context "Panel-bar assigment" do 
+    before do
+      @h=200
+      @w=200
+      @vis = Rubyvis.Panel.new.width(@w).height(@h)
+      @bar = @vis.add(Rubyvis::Bar).data([1,2,3])
+      @anchor=@bar.anchor('center')
+      @label=@anchor.add(Rubyvis::Label)
+      
+    end
+    
+    it "should have correct data for direct asigment" do
+      datas=[]
+      expected=[[1,nil],[2,nil],[3,nil]]
+      @label.text(lambda {|*args| datas.push args})
+      @vis.render
+      datas.should==expected
+    end
+    
+    it "should have correct data for two levels of data" do
+      datas=[]
+      @vis.data(%w{a b c})
+      expected=[]
+      %w{a b c}.each {|a| [1,2,3].each {|b| expected.push([b,a])}}
+      @label.text(lambda {|*args| datas.push args})
+      @vis.render
+      datas.should==expected
+    end
+  end  
+end
diff --git a/spec/area_spec.rb b/spec/area_spec.rb
new file mode 100644
index 0000000..5b5f57c
--- /dev/null
+++ b/spec/area_spec.rb
@@ -0,0 +1,143 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Area do
+  include Rubyvis::GeneralSpec
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :cursor, :data, :events, :fill_style, :height, :id, :interpolate, :left, :line_width, :reverse, :right, :segmented, :stroke_style, :tension, :title, :top, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Area.properties.should==props
+  end
+  it "Rubyvis.Area be the same as Rubyvis::Area" do
+    Rubyvis.Area.should eql Rubyvis::Area
+  end
+  it "should render equal to protovis 'area-segmented.html' test" do
+    data=Rubyvis.range(0, 6, 0.1).map {|x| Math.sin(x)}
+    vis = Rubyvis.Panel.new().
+width(500).
+height(200).
+top(50).
+bottom(50).
+left(10).
+right(10)
+
+    vis.add(Rubyvis::Area).
+segmented(true).
+data(data).
+bottom(0).
+left(lambda {self.index / 59.0 * 500}).
+height(lambda {|d| (d + 1) / 2.0 * 200 + 50}).
+fill_style(lambda {|d| "hsl(#{(d + 1) * 180.0},50,50)"})
+     vis.render()
+     pv_out=fixture_svg_read("area_segmented.svg")
+     vis.to_svg.should have_same_svg_elements(pv_out)
+  end
+  
+  it "should render correctly 'area_interpolation.html' example" do
+    data = pv.range(0, 10, 1).map {|x|
+    OpenStruct.new({:x=>x, :y=>Math.sin(x) + 2})}
+      
+      p_w=200
+      p_h=150
+      w = 20+p_w*2
+      h = 20+p_h*4
+      
+      p_w=200
+      p_h=150
+      #p data
+      w = 20+p_w*2
+      h = 20+p_h*4
+      
+      x = pv.Scale.linear(data, lambda {|d| d.x}).range(0, p_w-30)
+      
+      
+      y = pv.Scale.linear(data, lambda {|d| d.y}).range(0, p_h-20);
+      color=pv.Colors.category19();
+      interpolations=["linear","step-before","step-after", "basis", "cardinal", "monotone"]
+      
+      #/* The root panel. */
+      vis = pv.Panel.new().
+width(w).
+height(h).
+bottom(20).
+left(20).
+right(10).
+top(5)
+      
+      interpolations.each_with_index do |inter,i|
+      n=i%2
+      m=(i/2).floor
+      panel=vis.add(Rubyvis::Panel).
+      left(n*(p_w+10)).
+      top(m*(p_h+10)).
+      width(p_w).
+      height(p_h)
+      panel.anchor('top').add(Rubyvis::Label).text(inter)
+      
+      panel.add(Rubyvis::Area).data(data).
+      bottom(0).
+      segmented(true).
+      fill_style(lambda {color[self.index]}).
+      left(lambda {|d| x.scale(d.x)}).
+      height(lambda {|d| y.scale(d.y)}).
+      interpolate(inter)
+  
+    end
+    vis.render()
+    pv_out=fixture_svg_read("area_interpolation.svg")
+    vis.to_svg.should have_same_svg_elements(pv_out)
+  end
+  
+  
+  
+  context "rendered" do
+    before do
+      @h=200
+      @w=200
+      @vis = Rubyvis.Panel.new.width(@w).height(@h)
+      @area=@vis.add(pv.Area).
+        data([1,2,1,4,1,5]).
+        height(lambda {|d| d*20}).
+        left(lambda {index*20}).
+        bottom(0)
+    end
+    it "should return correct path with 0 on one value" do
+      
+      @area.data([1,0,2])
+      @vis.render
+
+
+      doc=Nokogiri::XML(@vis.to_svg)
+      # <svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="200" height="200"><g><path d="M0,180L20,200L20,200L0,200ZM20,200L40,160L40,200L20,200Z" fill="rgb(31,119,180)"/></g></svg>
+      doc.at_xpath("//xmlns:path").should have_path_data_close_to  "M0,180L20,200L20,200L0,200ZM20,200L40,160L40,200L20,200Z"
+    end
+    
+    
+    it "should return correct default (linear) path" do
+      @vis.render
+      doc=Nokogiri::XML(@vis.to_svg)
+      doc.at_xpath("//xmlns:path").should have_path_data_close_to  "M0 180L20 160L40 180L60 120L80 180L100 100L100 200L80 200L60 200L40 200L20 200L0 200Z"
+    end
+    it "should return correct path for interpolate=step-before" do
+      @area.interpolate('step-before')
+      @vis.render
+      doc=Nokogiri::XML(@vis.to_svg)
+      doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0 180V160L20 160V180L40 180V120L60 120V180L80 180V100L100 100L100 200H80L80 200H60L60 200H40L40 200H20L20 200H0L0 200Z"
+    end
+    it "should return correct path for interpolate=step-after" do
+      @area.interpolate('step-after')
+      @vis.render
+      doc=Nokogiri::XML(@vis.to_svg)
+      doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0 180H20L20 160H40L40 180H60L60 120H80L80 180H100L100 100L100 200V200L80 200V200L60 200V200L40 200V200L20 200V200L0 200Z"
+    end
+    it "should return correct path for interpolate=basis" do
+      @area.interpolate('basis')
+      @vis.render
+      doc=Nokogiri::XML(@vis.to_svg)
+      doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0 180C0 180 0 180 3.333333333333333 176.66666666666666C6.666666666666666 173.33333333333331 13.333333333333332 166.66666666666666 20 166.66666666666666C26.666666666666664 166.66666666666666 33.33333333333333 173.33333333333331 40 166.66666666666666C46.666666666666664 160 53.33333333333333 140 60 140C66.66666666666666 140 73.33333333333333 160 80 156.66666666666666C86.66666666666666 153.33333333333331 93.33333333333331 12 [...]
+    end   
+    it "should return correct path for interpolate=cardinal" do 
+      @area.interpolate('cardinal')
+      @vis.render
+      doc=Nokogiri::XML(@vis.to_svg)
+      doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0 180Q16 160 20 160C26 160 34 186 40 180S54 120 60 120S74 183 80 180Q84 178 100 100L100 200Q84 200 80 200C74 200 66 200 60 200S46 200 40 200S26 200 20 200Q16 200 0 200Z"
+    end
+  end
+end
\ No newline at end of file
diff --git a/spec/bar_spec.rb b/spec/bar_spec.rb
new file mode 100644
index 0000000..65a5025
--- /dev/null
+++ b/spec/bar_spec.rb
@@ -0,0 +1,77 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+  describe Rubyvis::Bar do
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :cursor, :data, :events, :fill_style, :height, :id, :left, :line_width, :reverse, :right, :stroke_style, :title, :top, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Bar.properties.should==props
+  end
+  it "Rubyvis.Bar be the same as Rubyvis::Bar" do
+    Rubyvis.Bar.should eql Rubyvis::Bar
+  end
+  it "should return correct defaults" do
+    props=Rubyvis::Bar.defaults._properties
+    props.size.should==2
+    props[0].name.should==:line_width
+    props[0].value.should==1.5
+    props[1].name.should==:fill_style
+    props[1].value.should be_instance_of Proc
+    Rubyvis::Bar.defaults.proto.should be_instance_of Rubyvis::Mark
+    
+  end
+  context "on a Panel" do 
+    before do
+      #Rubyvis.clear_document
+    @h=200
+    @w=200
+    @vis = Rubyvis.Panel.new.width(@w).height(@h)
+    @bar=@vis.add(pv.Bar).data([1,2]).width(20).height(lambda {|d| d * 80}).bottom(0).left(lambda {self.index * 25});
+    end
+    it "should bould propertly" do
+      @vis.render
+      s=@vis.to_svg
+      doc=Nokogiri::XML(s)
+      attribs=doc.xpath("//xmlns:rect").map {|v|
+      [v.attributes['y'].value, v.attributes['height'].value, v.attributes['fill'].value]
+      }
+      attribs.should==[["120","80","rgb(31,119,180)"],["40","160","rgb(31,119,180)"]]
+    end
+    
+    it "should bould properly with string fill_style" do
+      @bar.fill_style('red')
+      @vis.render
+      s=@vis.to_svg
+      doc=Nokogiri::XML(s)
+      doc.at_xpath("//xmlns:rect").attributes['fill'].value.should=='rgb(255,0,0)'
+    end
+    it "should bould properly with pv.color" do
+      @bar.fill_style(pv.color('red'))
+      @vis.render
+      s=@vis.to_svg
+      doc=Nokogiri::XML(s)
+      doc.at_xpath("//xmlns:rect").attributes['fill'].value.should=='rgb(255,0,0)'
+    end
+    it "should bould properly with pv.colors" do
+      @bar.fill_style(pv.colors('black','red'))
+      @vis.render
+      s=@vis.to_svg
+      doc=Nokogiri::XML(s)
+      attr=doc.xpath("//xmlns:rect").map {|x| x.attributes['fill'].value}
+      attr.should==['rgb(0,0,0)', 'rgb(255,0,0)']
+    end
+    
+    it "should bould propertly with double data" do
+      @vis = Rubyvis.Panel.new.width(@w).height(100)
+      @vis.add(pv.Bar).data([1,2]).width(20).height(lambda {|d| d * 10}).bottom(0).left(lambda {self.index * 25}).add(pv.Bar).width(10).height(lambda {|d| d * 30}).bottom(0).left(lambda {self.index * 25});
+      @vis.render
+      s=@vis.to_svg
+      doc=Nokogiri::XML(s)
+      attribs=doc.xpath("//xmlns:rect").map {|v|
+      x=v.attributes['x'] ? v.attributes['x'].value : nil
+        [x, v.attributes['y'].value, v.attributes['height'].value]
+      }
+      attribs.should==[[nil,"90","10"], ["25","80","20"], [nil,"70","30"], ["25","40","60"]]
+    end
+    
+  end  
+  
+  
+end
\ No newline at end of file
diff --git a/spec/color_spec.rb b/spec/color_spec.rb
new file mode 100644
index 0000000..9e7ae77
--- /dev/null
+++ b/spec/color_spec.rb
@@ -0,0 +1,91 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe "Rubyvis color methods" do
+  it "should return correct Rubyvis.ramp" do
+    a=Rubyvis.ramp("white","red")
+    a[0].should eq Rubyvis.color("rgb(255,255,255)")
+    a[0.5].should eq Rubyvis.color("rgb(255,128,128)")
+    a[1].should eq Rubyvis.color("rgb(255,0,0)")
+  end
+  
+  # <li>#f00 // #rgb
+  # <li>#ff0000 // #rrggbb
+  # <li>rgb(255, 0, 0)
+  # <li>rgb(100%, 0%, 0%)
+  # <li>hsl(0, 100%, 50%)
+  # <li>rgba(0, 0, 255, 0.5)
+  # <li>hsla(120, 100%, 50%, 1)
+  describe "Rubyvis.color" do 
+    
+    it "should return correct Rubyvis.color with three hex" do
+      Rubyvis.color("#f97").should eq Rubyvis::Color::Rgb.new("ff".to_i(16), "99".to_i(16),"77".to_i(16),1 )
+    end
+    it "should return correct Rubyvis.color with 6 hex" do
+      Rubyvis.color("#f19171").should eq Rubyvis::Color::Rgb.new("f1".to_i(16), "91".to_i(16),"71".to_i(16),1 )
+    end
+    it "should return correct Rubyvis.color rbg() with integers" do
+      r,g,b=rand(255),rand(255),rand(255)
+      Rubyvis.color("rgb(#{r},#{g},#{b})").should eq Rubyvis::Color::Rgb.new(r, g, b,1 )
+    end
+    it "should return correct Rubyvis.color rbga() with integers" do
+      r,g,b,a=rand(255),rand(255),rand(255), rand()
+      Rubyvis.color("rgba(#{r},#{g},#{b},#{a})").should eq Rubyvis::Color::Rgb.new(r, g, b,"#{a}".to_f )
+    end
+    it "should return correct Rubyvis.color rbg() with percents" do
+      r,g,b=rand(100),rand(100),rand(100)
+      Rubyvis.color("rgb(#{r}%,#{g}%,#{b}%)").should eq Rubyvis::Color::Rgb.new((r*2.55).round, (g*2.55).round, (b*2.55).round,1 )
+    end
+    it "should return correct Rubyvis.color hsl" do
+      Rubyvis.color("hsl(100,50,50)").should eq Rubyvis::Color::Rgb.new(106,191,64,1)
+      
+      h,s,l=rand(360),rand(100),rand(100)
+      
+      Rubyvis.color("hsl(#{h},#{s},#{l})").should eq Rubyvis::Color::Hsl.new(h,s/100.0,l/100.0,1).rgb
+    end
+    it "should return correct Rubyvis.color hsla" do
+      h,s,l,a=rand(360),rand(100),rand(100), rand()
+      Rubyvis.color("hsla(#{h},#{s},#{l},#{a})").should eq Rubyvis::Color::Hsl.new(h,s/100.0,l/100.0, "#{a}".to_f).rgb
+    end
+  end
+  describe Rubyvis::Color::Hsl do
+    it "convert some extreme value" do
+      Rubyvis.color("hsl(96,50,50)").should eq Rubyvis.color("rgb(115,191,64)")
+      Rubyvis.color("hsl(112.5,50.0,50.0)").should eq Rubyvis.color("rgb(80,191,64)")
+
+    end
+  end
+  describe Rubyvis::Color::Rgb do
+    before do
+      @r, at g, at b, at a=rand(255),rand(255),rand(255),rand()
+      @rgb=Rubyvis::Color::Rgb.new(@r, at g, at b, at a)
+    end
+    it "return correct ==" do
+      Rubyvis::Color::Rgb.new(0, 0,0,1 ).should eq Rubyvis::Color::Rgb.new(0, 0,0,1 )
+      
+      Rubyvis::Color::Rgb.new(10, 0,0,1 ).should_not eq Rubyvis::Color::Rgb.new(0, 0,0,1 )
+      
+      Rubyvis::Color::Rgb.new(0, 10,0,1 ).should_not eq Rubyvis::Color::Rgb.new(0, 0,0,1 )
+      
+      Rubyvis::Color::Rgb.new(0, 0,10,1 ).should_not eq Rubyvis::Color::Rgb.new(0, 0,0,1 )
+      Rubyvis::Color::Rgb.new(0, 0,0,0 ).should_not eq Rubyvis::Color::Rgb.new(0, 0,0,1 )
+    end
+    it "return correct red()" do
+      @rgb.red(255).should eq Rubyvis::Color::Rgb.new(255, at g, at b, at a)
+    end
+    it "return correct green()" do
+      @rgb.green(255).should eq Rubyvis::Color::Rgb.new(@r,255, at b, at a)
+    end
+    it "return correct blue()" do
+      @rgb.blue(255).should eq Rubyvis::Color::Rgb.new(@r, at g,255, at a)
+    end
+    it "return correct alpha()" do
+      @rgb.alpha(0.5).should eq Rubyvis::Color::Rgb.new(@r, at g, at b,0.5)
+    end
+    it "return correct darker()" do
+      Rubyvis.color("red").darker().should eq Rubyvis::Color::Rgb.new(178,0,0,1)
+    end
+    it "return correct brighter()" do
+      Rubyvis.color("rgb(100,110,120)").brighter().should eq Rubyvis::Color::Rgb.new(142,157,171,1)
+    end    
+    
+  end
+end
diff --git a/spec/dom_spec.rb b/spec/dom_spec.rb
new file mode 100644
index 0000000..cd3a57c
--- /dev/null
+++ b/spec/dom_spec.rb
@@ -0,0 +1,225 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Dom do
+  it "should map correctly" do
+    map={
+      :a=>{:aa=>1,
+           :ab=>{:aba=>2}
+          },
+      :b=>4,
+      :c=>{:ca=>5}
+    }
+    dom_map=Rubyvis::Dom.new(map)       
+    
+    root=dom_map.root.sort {|a,b| a.node_name.to_s<=>b.node_name.to_s}
+    root.nodes.should be_instance_of Array
+    root.nodes.size.should eq 8
+    ar=root.nodes.map do |n|
+      [n.node_name, n.node_value]
+    end
+    ar.should eq [[nil, nil], [:a, nil], [:aa, 1], [:ab, nil], [:aba, 2], [:b, 4], [:c, nil], [:ca, 5]]
+  end
+  it "should treemap example works right" do
+    flare={:a=>{:aa=>1,:ab=>1,:ac=>1},:b=>{:ba=>1,:bb=>1},:c=>3}
+    dom_map=Rubyvis::Dom.new(flare)
+    nodes = dom_map.root("flare").nodes
+    root = nodes[0]
+    root.visit_after {|nn,i|
+      if nn.first_child
+        nn.size=Rubyvis.sum(nn.child_nodes, lambda {|v| v.size})
+       else
+         nn.size=nn.node_value.to_f
+       end
+    }
+    root.sort(lambda {|a,b| 
+        if a.size!=b.size
+          a.size<=>b.size 
+        else
+          a.node_name.to_s<=>b.node_name.to_s
+        end
+          
+    })
+    ar=[]
+    root.visit_before {|n,i|
+      ar.push [n.node_name, n.size]
+    }
+    ar.should eq [["flare", 8.0], [:b, 2.0], [:ba, 1.0], [:bb, 1.0], [:a, 3.0], [:aa, 1.0], [:ab, 1.0], [:ac, 1.0], [:c, 3.0]]
+  end
+  describe Rubyvis::Dom::Node do
+    before do
+      @n =Rubyvis::Dom::Node.new(:a)
+      @n2=Rubyvis::Dom::Node.new(:b)
+      @n3=Rubyvis::Dom::Node.new(:c)
+      @n4=Rubyvis::Dom::Node.new(:d)
+      @n5=Rubyvis::Dom::Node.new(:e)
+      
+    end
+    subject {@n}
+    it "should have node_value" do 
+      @n.node_value.should eq :a
+    end
+    it  {should respond_to :parent_node}
+    it  {should respond_to :first_child}
+    it  {should respond_to :last_child}
+    it  {should respond_to :previous_sibling}
+    it  {should respond_to :next_sibling}
+    it  {should respond_to :node_name}
+    it  {should respond_to :child_nodes}
+    it "should child_nodes be empty" do
+      @n.child_nodes.size==0
+    end
+    it "method append_child" do
+      @n.append_child(@n2).should eq @n2
+      @n.child_nodes.should eq [@n2]
+      @n2.parent_node.should eq @n
+      @n.first_child.should eq @n2
+      @n.last_child.should eq @n2
+      
+      @n.append_child(@n3)
+      @n.child_nodes.should eq [@n2, at n3]
+      @n3.parent_node.should eq @n
+      @n.first_child.should eq @n2
+      @n.last_child.should eq @n3
+      @n2.previous_sibling.should be_nil
+      @n2.next_sibling.should eq @n3
+      @n3.previous_sibling.should eq @n2
+      @n3.next_sibling.should be_nil
+      
+      @n.append_child(@n4)
+      @n.last_child.should eq @n4
+      @n2.next_sibling.should eq @n3
+      @n3.next_sibling.should eq @n4
+      @n4.next_sibling.should be_nil
+
+      @n4.previous_sibling.should eq @n3
+      @n3.previous_sibling.should eq @n2
+      @n2.previous_sibling.should be_nil
+      
+    end
+    it "method remove_child" do
+      @n.append_child(@n2)
+      @n.append_child(@n3)
+      @n.append_child(@n4)
+      
+      @n.remove_child(@n3).should eq @n3
+      
+      @n3.next_sibling.should be_nil
+      @n3.previous_sibling.should be_nil
+      @n3.parent_node.should be_nil
+      
+      @n2.next_sibling.should eq @n4
+      @n4.previous_sibling.should eq @n2
+      
+      @n.remove_child(@n4)
+      @n2.next_sibling.should be_nil
+      @n.first_child.should eq @n2
+      @n.last_child.should eq @n2
+    end
+    
+    it "method insert_before" do
+      @n.append_child(@n2)
+      @n.append_child(@n4)
+      @n.insert_before(@n3, at n4)
+      @n.child_nodes.size.should eq 3
+      
+      @n.first_child.should eq @n2
+      @n.last_child.should eq @n4
+      @n2.next_sibling.should eq @n3
+      @n3.next_sibling.should eq @n4
+      @n4.next_sibling.should be_nil
+     
+      @n2.previous_sibling.should be_nil
+      @n3.previous_sibling.should eq @n2
+      @n4.previous_sibling.should eq @n3
+      
+      
+      
+      @n.child_nodes[0].should eq @n2
+      @n.child_nodes[1].should eq @n3
+      @n.child_nodes[2].should eq @n4
+      
+    end
+    it "method replace_child" do
+      @n.append_child(@n2)
+      @n.append_child(@n3)
+      @n.replace_child(@n4, at n3)
+      
+      @n.child_nodes.size.should eq 2
+      
+      @n.child_nodes[0].should eq @n2
+      @n.child_nodes[1].should eq @n4
+
+      @n2.next_sibling.should eq @n4
+      @n4.next_sibling.should eq nil
+     
+      @n2.previous_sibling.should be_nil
+      @n4.previous_sibling.should eq @n2
+
+      
+      @n.first_child.should eq @n2
+      @n.last_child.should eq @n4
+    end
+    describe "visit methods" do
+      before do
+        @n.append_child(@n2)
+        @n2.append_child(@n5)
+        
+        @n.append_child(@n3)
+        @n3.append_child(@n4)
+        @a=[]
+      end
+      
+      it "method visit_before" do
+        @n.visit_before {|n,d|
+          @a.push([n.node_value,d])
+        }
+        @a.should eq [[:a, 0], [:b, 1], [:e, 2], [:c, 1], [:d, 2]]
+      end
+      
+      it "method visit_after" do
+        @n.visit_after {|n,d|
+          @a.push([n.node_value,d])
+        }
+        @a.should eq [[:e, 2], [:b, 1], [:d, 2], [:c, 1], [:a, 0]]
+      end
+      it "method each_child" do
+        @n.append_child(@n5)        
+        @n.each_child {|d|
+          @a.push(d.node_value)
+        }
+        @a.should eq [:b, :c,:e]
+      end
+    end
+    it "should sort correctly" do
+      @n.append_child(@n5)
+      @n.append_child(@n4)
+      @n.append_child(@n3)
+      @n.append_child(@n2)
+      
+      @n.sort {|a,b| a.node_value.to_s<=>b.node_value.to_s}
+      
+      @n.child_nodes.should eq [@n2, at n3, at n4, at n5]
+      
+      @n.first_child.should eq @n2
+      @n.last_child.should eq @n5
+      
+      @n2.next_sibling.should eq @n3
+      @n3.next_sibling.should eq @n4
+      @n4.next_sibling.should eq @n5
+      @n5.next_sibling.should be_nil
+
+      @n2.previous_sibling.should be_nil
+      @n3.previous_sibling.should eq @n2
+      @n4.previous_sibling.should eq @n3
+      @n5.previous_sibling.should eq @n4
+    end
+    it "should reverse correctly" do
+      @n.append_child(@n3)
+      @n.append_child(@n5)
+      @n.append_child(@n2)
+      @n.append_child(@n4)
+      @n.reverse
+      @n.child_nodes.should eq [@n4, at n2, at n5, at n3]
+    end
+    
+  end
+end
\ No newline at end of file
diff --git a/spec/dot_spec.rb b/spec/dot_spec.rb
new file mode 100644
index 0000000..7b6a27a
--- /dev/null
+++ b/spec/dot_spec.rb
@@ -0,0 +1,41 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+  describe Rubyvis::Dot do
+    include Rubyvis::GeneralSpec
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :cursor, :data, :events, :fill_style,  :id, :left, :line_width, :reverse, :right, :shape, :shape_angle, :shape_radius, :shape_size, :stroke_style, :title, :top, :visible].inject({}) {|ac, v| ac[v]=true; ac}
+    
+    Rubyvis::Dot.properties.should==props
+  end
+  it "Rubyvis.Dot be the same as Rubyvis::Dot" do
+    Rubyvis.Dot.should eql Rubyvis::Dot
+  end
+  
+  it "should render correctly 'dot-anchor' example" do
+    w = 400
+    h = 400
+    
+    vis = Rubyvis::Panel.new().
+      width(w).
+      height(h).
+      margin(20).
+      stroke_style("#ccc");
+    
+    dot = vis.add(Rubyvis::Dot).
+      top(w / 2.0).
+      left(w / 2.0).
+      shape_radius(w >> 2)
+    
+    dot.anchor("top").add(Rubyvis::Label).text("top");
+    dot.anchor("left").add(Rubyvis::Label).text("left");
+    dot.anchor("right").add(Rubyvis::Label).text("right");
+    dot.anchor("bottom").add(Rubyvis::Label).text("bottom");
+    dot.anchor("center").add(Rubyvis::Label).text("center");
+    
+    vis.render()
+    
+    pv_out=fixture_svg_read("dot_anchor.svg")
+    vis.to_svg.should have_same_svg_elements(pv_out)
+  end
+  
+  
+end
\ No newline at end of file
diff --git a/spec/fixtures/anchor.html b/spec/fixtures/anchor.html
new file mode 100644
index 0000000..c4e27f4
--- /dev/null
+++ b/spec/fixtures/anchor.html
@@ -0,0 +1,25 @@
+<html>
+  <head>
+    <title>Anchor</title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+  </head>
+  <body>
+    <script type="text/javascript+protovis">
+
+var vis = new pv.Panel()
+    .width(200)
+    .height(200)
+
+vis.add(pv.Bar)
+    .fillStyle("#ccc")
+  .anchor("top").add(pv.Label)
+    .text("top")
+    .anchorTarget()
+  .anchor("bottom").add(pv.Label)
+    .text("bottom");
+
+vis.render();
+
+    </script>
+  </body>
+</html>
diff --git a/spec/fixtures/anchor.svg b/spec/fixtures/anchor.svg
new file mode 100644
index 0000000..cae292a
--- /dev/null
+++ b/spec/fixtures/anchor.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="200" height="200"><g><rect width="200" height="200" fill="rgb(204,204,204)"/></g><g><text pointer-events="none" y="3" dy="0.71em" transform="translate(100)" fill="rgb(0,0,0)" text-anchor="middle">top</text></g><g><text pointer-events="none" y="-3" transform="translate(100, 200)" fill="rgb(0,0,0)" text-anchor="middle">bottom</text></g></svg>
diff --git a/spec/fixtures/area-segmented.html b/spec/fixtures/area-segmented.html
new file mode 100644
index 0000000..7614c07
--- /dev/null
+++ b/spec/fixtures/area-segmented.html
@@ -0,0 +1,29 @@
+<html>
+  <head>
+    <title>Segmented Area</title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+  </head>
+  <body>
+    <script type="text/javascript+protovis">
+
+var vis = new pv.Panel()
+    .width(500)
+    .height(200)
+    .top(50)
+    .bottom(50)
+    .left(10)
+    .right(10);
+
+vis.add(pv.Area)
+    .segmented(true)
+    .data(function() pv.range(0, 6, .1).map(Math.sin))
+    .bottom(0)
+    .left(function() this.index / 59 * 500)
+    .height(function(d) (d + 1) / 2 * 200 + 50)
+    .fillStyle(function(d) {console.log((d+1)*180);return "hsl(" + (d + 1) * 180 + ",50,50)"});
+
+vis.render();
+
+    </script>
+  </body>
+</html>
diff --git a/spec/fixtures/area_interpolation.html b/spec/fixtures/area_interpolation.html
new file mode 100644
index 0000000..7466887
--- /dev/null
+++ b/spec/fixtures/area_interpolation.html
@@ -0,0 +1,66 @@
+<html>
+  <head>
+    <title>Test: Area interpolation and segmentation</title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+  </head>
+  <body>
+  <h1>Test: Area interpolation and segmentation</h1>
+    <script type="text/javascript">
+
+data = pv.range(0, 10, 1).map(function(x) {
+  return {x:x, y:Math.sin(x) + 2};
+});
+
+
+p_w=200
+p_h=150
+w = 20+p_w*2
+h = 20+p_h*4
+
+x = pv.Scale.linear(data, function(d) {return d.x;}).range(0, p_w-30)
+
+
+y = pv.Scale.linear(data, function(d) {return d.y;}).range(0, p_h-20);
+
+color=pv.Colors.category19();
+interpolations=["linear","step-before","step-after", "basis", "cardinal","monotone"]
+
+vis = new pv.Panel()
+  .width(w)
+  .height(h)
+  .bottom(20)
+  .left(20)
+  .right(10)
+  .top(5)
+
+for(var i=0; i<interpolations.length;i++) {
+var inter=interpolations[i];
+  n=i%2
+  m=Math.floor(i/2)
+  panel=vis.add(pv.Panel).
+  left(n*(p_w+10)).
+  top(m*(p_h+10)).
+  width(p_w).
+  height(p_h)
+  
+  panel.anchor('top').add(pv.Label).text(inter)
+  
+  panel.add(pv.Area).data(data).
+  bottom(0).
+  segmented(true).
+  fillStyle(function() {return color(this.index);}).
+  left(function(d){return x(d.x)}).
+  height(function(d){ return y(d.y)}).
+  interpolate(inter);
+  }
+  
+  
+     
+
+vis.render()
+
+
+
+</script>
+    </body>
+    </html>
\ No newline at end of file
diff --git a/spec/fixtures/area_interpolation.svg b/spec/fixtures/area_interpolation.svg
new file mode 100644
index 0000000..79c8bb0
--- /dev/null
+++ b/spec/fixtures/area_interpolation.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="450" height="645"><g transform="translate(20, 5)"><g><text pointer-events="none" y="3" dy="0.71em" transform="translate(100)" fill="rgb(0,0,0)" text-anchor="middle">linear</text></g><g><path d="M0,86.01536001878696L18.88888888888889,29.86784197156267L18.88888888888889,150L0,150Z" fill="rgb(156,158,222)"/><path d="M18.88888888888889,29.86784197156267L37.77777777777778,25.342093079410418L37.7 [...]
diff --git a/spec/fixtures/area_segmented.svg b/spec/fixtures/area_segmented.svg
new file mode 100644
index 0000000..fa49403
--- /dev/null
+++ b/spec/fixtures/area_segmented.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="520" height="300"><g transform="translate(10, 50)"><path d="M0,50L8.474576271186441,40.016658335317175L8.474576271186441,200L0,200Z" fill="rgb(64,191,191)"/><path d="M8.474576271186441,40.016658335317175L16.949152542372882,30.13306692049386L16.949152542372882,200L8.474576271186441,200Z" fill="rgb(64,153,191)"/><path d="M16.949152542372882,30.13306692049386L25.423728813559325,20.447979333866 [...]
diff --git a/spec/fixtures/dot-anchor.html b/spec/fixtures/dot-anchor.html
new file mode 100644
index 0000000..890efad
--- /dev/null
+++ b/spec/fixtures/dot-anchor.html
@@ -0,0 +1,33 @@
+<html>
+  <head>
+    <title>Scatterplot</title>
+    <script type="text/javascript" src="protovis-d3.3.js"></script>
+  </head>
+  <body>
+    <script type="text/javascript+protovis">
+
+var w = 400,
+    h = 400;
+
+var vis = new pv.Panel()
+    .width(w)
+    .height(h)
+    .margin(20)
+    .strokeStyle("#ccc");
+
+var dot = vis.add(pv.Dot)
+    .top(w / 2)
+    .left(w / 2)
+    .shapeRadius(w >> 2);
+
+dot.anchor("top").add(pv.Label).text("top");
+dot.anchor("left").add(pv.Label).text("left");
+dot.anchor("right").add(pv.Label).text("right");
+dot.anchor("bottom").add(pv.Label).text("bottom");
+dot.anchor("center").add(pv.Label).text("center");
+
+vis.render();
+
+    </script>
+  </body>
+</html>
diff --git a/spec/fixtures/dot_anchor.svg b/spec/fixtures/dot_anchor.svg
new file mode 100644
index 0000000..f901ca6
--- /dev/null
+++ b/spec/fixtures/dot_anchor.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="440" height="440"><g transform="translate(20, 20)"><circle stroke="rgb(31,119,180)" cx="200" cy="200" r="100"/></g><g transform="translate(20, 20)"><text pointer-events="none" y="-3" transform="translate(200, 100)" fill="rgb(0,0,0)" text-anchor="middle">top</text></g><g transform="translate(20, 20)"><text pointer-events="none" x="-3" dy="0.35em" transform="translate(100, 200)" fill="rgb(0,0 [...]
diff --git a/spec/fixtures/image.svg b/spec/fixtures/image.svg
new file mode 100644
index 0000000..4518efd
--- /dev/null
+++ b/spec/fixtures/image.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="440" height="440"><g transform="translate(20,20)"><image preserveAspectRatio="none" width="400" height="400" xlink:href="fixtures/tipsy.gif"/></g><rect x="20" y="20" width="400" height="400" fill="none" stroke="rgb(204,204,204)"/></svg>
diff --git a/spec/fixtures/layers.js b/spec/fixtures/layers.js
new file mode 100644
index 0000000..2021e9c
--- /dev/null
+++ b/spec/fixtures/layers.js
@@ -0,0 +1,28 @@
+/* Inspired by Lee Byron's test data generator. */
+function layers(n, m) {
+  function bump(a) {
+    var x = 1 / (.1 + Math.sin(n)),
+        y = 2 * Math.cos(m) - .5,
+        z = 10 / (.1 + Math.sin(x));
+    for (var i = 0; i < m; i++) {
+      var w = (i / m - y) * z;
+      a[i] += x * Math.exp(-w * w);
+    }
+  }
+  return pv.range(n).map(function() {
+      var a = [], i;
+      for (i = 0; i < m; i++) a[i] = 0;
+      for (i = 0; i < 5; i++) bump(a);
+      return a;
+    });
+}
+
+/* Another layer generator using gamma distributions. */
+function waves(n, m) {
+  return pv.range(n).map(function(i) {
+    return pv.range(m).map(function(j) {
+        var x = 20 * j / m - i / 3;
+        return x > 0 ? 2 * x * Math.exp(-.5 * x) : 0;
+      });
+    });
+}
diff --git a/spec/fixtures/layout_arc.svg b/spec/fixtures/layout_arc.svg
new file mode 100644
index 0000000..b3ad856
--- /dev/null
+++ b/spec/fixtures/layout_arc.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="300" height="150"><g><g><g><path shape-rendering="crispEdges" d="M25,100A25,25 0 0,1 75,100" stroke="rgb(0,0,0)" stroke-opacity="0.2" stroke-width="1"/></g><g><path shape-rendering="crispEdges" d="M75,100A25,25 0 0,1 125,100" stroke="rgb(0,0,0)" stroke-opacity="0.2" stroke-width="1"/></g><g><path shape-rendering="crispEdges" d="M125,100A25,25 0 0,1 175,100" stroke="rgb(0,0,0)" stroke-opacit [...]
diff --git a/spec/fixtures/layout_cluster.html b/spec/fixtures/layout_cluster.html
new file mode 100644
index 0000000..ac2efae
--- /dev/null
+++ b/spec/fixtures/layout_cluster.html
@@ -0,0 +1,39 @@
+<html>
+  <head>
+    <title>Test: Layout Partition</title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+  </head>
+  <body>
+  <h1>Test: Layout Partition</h1>
+    <script type="text/javascript">
+color=pv.Colors.category19()
+w=400
+h=400
+
+subtree={a:1,b:2,c:3,d:4}
+
+hier_nodes=pv.dom({a:subtree,b:subtree, c:subtree, d:subtree,e:subtree,f:subtree}).root("test").nodes()
+
+
+vis = new pv.Panel()
+    .width(w)
+    .height(h)
+    .top(20)
+    .bottom(10)
+    .left(10)
+
+partition= vis.add(pv.Layout.Cluster).
+  nodes(hier_nodes).orient("top")
+
+partition.node.add(pv.Dot).
+  fillStyle(function(d) {return color(d.nodeValue);}).
+  strokeStyle("black").
+  lineWidth(1).
+  antialias(false)
+partition.link.add(pv.Line)
+partition.label.add(pv.Label).
+text(function(d) {return d.nodeName})
+vis.render()
+</script>
+    </body>
+    </html>
\ No newline at end of file
diff --git a/spec/fixtures/layout_cluster.svg b/spec/fixtures/layout_cluster.svg
new file mode 100644
index 0000000..3ed98c4
--- /dev/null
+++ b/spec/fixtures/layout_cluster.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="410" height="430"><g transform="translate(10, 20)"><g><circle shape-rendering="crispEdges" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width="1" cx="199.99999999999997" cy="0" r="4.5"/><circle shape-rendering="crispEdges" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width="1" cx="33.33333333333333" cy="200" r="4.5"/><circle shape-rendering="crispEdges" fill="rgb(115,117,181)" s [...]
diff --git a/spec/fixtures/layout_cluster_left_group_2.html b/spec/fixtures/layout_cluster_left_group_2.html
new file mode 100644
index 0000000..12a8f30
--- /dev/null
+++ b/spec/fixtures/layout_cluster_left_group_2.html
@@ -0,0 +1,39 @@
+<html>
+  <head>
+    <title>Test: Layout Partition</title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+  </head>
+  <body>
+  <h1>Test: Layout Partition</h1>
+    <script type="text/javascript">
+color=pv.Colors.category19()
+w=400
+h=400
+
+subtree={a:1,b:2,c:3,d:4}
+
+hier_nodes=pv.dom({a:subtree,b:subtree, c:subtree, d:subtree,e:subtree,f:subtree}).root("test").nodes()
+
+
+vis = new pv.Panel()
+    .width(w)
+    .height(h)
+    .top(20)
+    .bottom(10)
+    .left(10)
+
+partition= vis.add(pv.Layout.Cluster).
+  nodes(hier_nodes).orient("left").group(2)
+
+partition.node.add(pv.Dot).
+  fillStyle(function(d) {return color(d.nodeValue);}).
+  strokeStyle("black").
+  lineWidth(1).
+  antialias(false)
+partition.link.add(pv.Line)
+partition.label.add(pv.Label).
+text(function(d) {return d.nodeName})
+vis.render()
+</script>
+    </body>
+    </html>
\ No newline at end of file
diff --git a/spec/fixtures/layout_cluster_left_group_2.svg b/spec/fixtures/layout_cluster_left_group_2.svg
new file mode 100644
index 0000000..479058f
--- /dev/null
+++ b/spec/fixtures/layout_cluster_left_group_2.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="410" height="430"><g transform="translate(10, 20)"><g><circle shape-rendering="crispEdges" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width="1" cx="0" cy="200" r="4.5"/><circle shape-rendering="crispEdges" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width="1" cx="200" cy="33.33333333333333" r="4.5"/><circle shape-rendering="crispEdges" fill="rgb(115,117,181)" stroke="rgb(0,0, [...]
diff --git a/spec/fixtures/layout_grid.html b/spec/fixtures/layout_grid.html
new file mode 100644
index 0000000..c83b497
--- /dev/null
+++ b/spec/fixtures/layout_grid.html
@@ -0,0 +1,34 @@
+<html>
+  <head>
+    <title>Grid Layout</title>
+    <script type="text/javascript" src="protovis-d3.3.js"></script>
+  </head>
+  <body>
+    <script type="text/javascript+protovis">
+
+var vis = new pv.Panel()
+    .data(["A"])
+    .width(800)
+    .height(800)
+    .margin(10)
+    .fillStyle("#eee")
+    .strokeStyle("#ccc");
+
+vis.add(pv.Layout.Grid)
+    .rows(3)
+    .cols(3)
+  .cell.add(pv.Layout.Grid)
+    .rows(pv.index)
+    .cols(pv.index)
+  .cell.add(pv.Bar)
+    .strokeStyle("#fff")
+  .anchor("center").add(pv.Label)
+    .textStyle("rgba(255, 255, 255, .4)")
+    .font("24px sans");
+
+vis.render();
+
+    </script>
+  </body>
+</html>
+
diff --git a/spec/fixtures/layout_grid.svg b/spec/fixtures/layout_grid.svg
new file mode 100644
index 0000000..2a25570
--- /dev/null
+++ b/spec/fixtures/layout_grid.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="820" height="820"><rect x="10" y="10" width="800" height="800" fill="rgb(238,238,238)"/><g transform="translate(10, 10)"><g><g/><g/><g transform="translate(266.667)"><rect width="266.6666666666667" height="266.6666666666667" fill="rgb(31,119,180)" stroke="rgb(255,255,255)"/></g><g transform="translate(266.667)"><text pointer-events="none" dy="0.35em" transform="translate(133.333, 133.333)"  [...]
diff --git a/spec/fixtures/layout_horizon.svg b/spec/fixtures/layout_horizon.svg
new file mode 100644
index 0000000..44205d9
--- /dev/null
+++ b/spec/fixtures/layout_horizon.svg
@@ -0,0 +1,24 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="430" height="245"><g transform="translate(20, 5)"><g transform="translate(0, 30)"><g><g clip-path="url(#87)"><clippath id="87"><rect x="0" y="0" width="400" height="80"/>
+</clippath><rect width="400" height="80" fill="rgb(255,255,255)"/><g><path d="M0,-120L4.0404040404040265,-110.10000000000005L8.080808080808087,-100.4L12.121212121212114,-90.90000000000003L16.161616161616173,-81.59999999999997L20.2020202020202,-72.5L24.242424242424228,-63.60000000000002L28.282828282828287,-54.89999999999998L32.32323232323232,-46.400000000000006L36.363636363636374,-38.099999999999994L40.4040404040404,-30L44.44444444444445,-22.099999999999994L48.48484848484849,-14.400000000 [...]
+</g>
+</g><g clip-path="url(#88)"><clippath id="88"><rect x="0" y="0" width="400" height="80"/>
+</clippath><g><path d="M0,-200L4.0404040404040265,-190.10000000000005L8.080808080808087,-180.4L12.121212121212114,-170.90000000000003L16.161616161616173,-161.59999999999997L20.2020202020202,-152.5L24.242424242424228,-143.60000000000002L28.282828282828287,-134.89999999999998L32.32323232323232,-126.4L36.363636363636374,-118.1L40.4040404040404,-110L44.44444444444445,-102.1L48.48484848484849,-94.4L52.52525252525252,-86.90000000000003L56.565656565656575,-79.59999999999997L60.60606060606061,-7 [...]
+</g>
+</g><g clip-path="url(#89)"><clippath id="89"><rect x="0" y="0" width="400" height="80"/>
+</clippath><g><path d="M0,-40L4.0404040404040265,-30.10000000000005L8.080808080808087,-20.400000000000006L12.121212121212114,-10.900000000000034L16.161616161616173,-1.599999999999966L20.2020202020202,7.5L24.242424242424228,16.399999999999977L28.282828282828287,25.100000000000023L32.32323232323232,33.599999999999994L36.363636363636374,41.900000000000006L40.4040404040404,50L44.44444444444445,57.900000000000006L48.48484848484849,65.6L52.52525252525252,73.09999999999997L56.565656565656575,80 [...]
+</g>
+</g><g clip-path="url(#8a)"><clippath id="8a"><rect x="0" y="0" width="400" height="80"/>
+</clippath><g><path d="M0,-280L4.0404040404040265,-270.1L8.080808080808087,-260.4L12.121212121212114,-250.90000000000003L16.161616161616173,-241.59999999999997L20.2020202020202,-232.5L24.242424242424228,-223.60000000000002L28.282828282828287,-214.89999999999998L32.32323232323232,-206.4L36.363636363636374,-198.1L40.4040404040404,-190L44.44444444444445,-182.1L48.48484848484849,-174.4L52.52525252525252,-166.90000000000003L56.565656565656575,-159.59999999999997L60.60606060606061,-152.5L64.64 [...]
+</g>
+</g><g clip-path="url(#8b)"><clippath id="8b"><rect x="0" y="0" width="400" height="80"/>
+</clippath><g><path d="M0,40L4.0404040404040265,49.89999999999995L8.080808080808087,59.599999999999994L12.121212121212114,69.09999999999997L16.161616161616173,78.40000000000003L20.2020202020202,87.5L24.242424242424228,96.39999999999998L28.282828282828287,105.10000000000002L32.32323232323232,113.6L36.363636363636374,121.9L40.4040404040404,130L44.44444444444445,137.9L48.48484848484849,145.6L52.52525252525252,153.09999999999997L56.565656565656575,160.40000000000003L60.60606060606061,167.5L6 [...]
+</g>
+</g><g clip-path="url(#8c)"><clippath id="8c"><rect x="0" y="0" width="400" height="80"/>
+</clippath><g><path d="M0,-360L4.0404040404040265,-350.1L8.080808080808087,-340.4L12.121212121212114,-330.90000000000003L16.161616161616173,-321.59999999999997L20.2020202020202,-312.5L24.242424242424228,-303.6L28.282828282828287,-294.9L32.32323232323232,-286.4L36.363636363636374,-278.1L40.4040404040404,-270L44.44444444444445,-262.1L48.48484848484849,-254.4L52.52525252525252,-246.90000000000003L56.565656565656575,-239.59999999999997L60.60606060606061,-232.5L64.64646464646465,-225.59999999 [...]
+</g>
+</g>
+</g>
+</g>
+</g>
+</svg>
+
diff --git a/spec/fixtures/layout_indent.html b/spec/fixtures/layout_indent.html
new file mode 100644
index 0000000..7473e3c
--- /dev/null
+++ b/spec/fixtures/layout_indent.html
@@ -0,0 +1,39 @@
+<html>
+  <head>
+    <title>Test: Layout Indent</title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+  </head>
+  <body>
+  <h1>Test: Layout Indent</h1>
+    <script type="text/javascript">
+color=pv.Colors.category19()
+w=200
+h=200
+
+subtree={a:1,b:2,c:3,d:4}
+
+hier_nodes=pv.dom({a:subtree,b:subtree, c:subtree, d:subtree,e:subtree,f:subtree}).root("test").nodes()
+
+
+vis = new pv.Panel()
+    .width(w)
+    .height(h)
+    .top(20)
+    .bottom(10)
+    .left(10)
+
+indent = vis.add(pv.Layout.Indent).
+  nodes(hier_nodes).breadth(10)
+
+indent.node.add(pv.Dot).
+  fillStyle(function(d) {return color(d.nodeValue);}).
+  strokeStyle("black").
+  lineWidth(1).
+  antialias(false)
+indent.link.add(pv.Line)  
+indent.label.add(pv.Label).
+text(function(d) {return d.nodeName})
+vis.render()
+</script>
+    </body>
+    </html>
\ No newline at end of file
diff --git a/spec/fixtures/layout_indent.svg b/spec/fixtures/layout_indent.svg
new file mode 100644
index 0000000..fa13f1b
--- /dev/null
+++ b/spec/fixtures/layout_indent.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="210" height="230"><g transform="translate(10, 20)"><g><circle shape-rendering="crispEdges" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width="1" cx="15" cy="10" r="4.5"/><circle shape-rendering="crispEdges" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width="1" cx="30" cy="20" r="4.5"/><circle shape-rendering="crispEdges" fill="rgb(115,117,181)" stroke="rgb(0,0,0)" stroke-width [...]
diff --git a/spec/fixtures/layout_matrix.svg b/spec/fixtures/layout_matrix.svg
new file mode 100644
index 0000000..4b785cf
--- /dev/null
+++ b/spec/fixtures/layout_matrix.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="750" height="750"><g transform="translate(50, 50)"><g><rect shape-rendering="crispEdges" width="116.66666666666667" height="116.66666666666667" fill="rgb(238,238,238)" stroke="rgb(255,255,255)" stroke-width="1"/><rect shape-rendering="crispEdges" x="116.66666666666667" width="116.66666666666667" height="116.66666666666667" fill="rgb(156,158,222)" stroke="rgb(255,255,255)" stroke-width="1"/> [...]
diff --git a/spec/fixtures/layout_pack.html b/spec/fixtures/layout_pack.html
new file mode 100644
index 0000000..8f2b4a9
--- /dev/null
+++ b/spec/fixtures/layout_pack.html
@@ -0,0 +1,38 @@
+<html>
+  <head>
+    <title>Test: Layout Indent</title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+  </head>
+  <body>
+  <h1>Test: Layout Indent</h1>
+    <script type="text/javascript">
+color=pv.Colors.category19()
+w=200
+h=200
+
+subtree={a:1,b:2,c:3,d:4}
+
+hier_nodes=pv.dom({a:subtree,b:subtree, c:subtree, d:subtree,e:subtree,f:subtree}).root("test").nodes()
+
+
+vis = new pv.Panel()
+    .width(w)
+    .height(h)
+    .top(20)
+    .bottom(10)
+    .left(10)
+
+indent = vis.add(pv.Layout.Pack).
+  nodes(hier_nodes)
+
+indent.node.add(pv.Dot).
+  fillStyle(function(d) {return color(d.nodeValue);}).
+  strokeStyle("black").
+  lineWidth(1).
+  antialias(false)
+indent.label.add(pv.Label).
+text(function(d) {return d.nodeName})
+vis.render()
+</script>
+    </body>
+    </html>
\ No newline at end of file
diff --git a/spec/fixtures/layout_pack.svg b/spec/fixtures/layout_pack.svg
new file mode 100644
index 0000000..ebf60b7
--- /dev/null
+++ b/spec/fixtures/layout_pack.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="210" height="230"><g transform="translate(10, 20)"><g><circle shape-rendering="crispEdges" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width="1" cx="100" cy="100" r="100"/><circle shape-rendering="crispEdges" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width="1" cx="100" cy="100" r="30.6002309434949"/><circle shape-rendering="crispEdges" fill="rgb(115,117,181)" stroke="rgb(0,0 [...]
diff --git a/spec/fixtures/layout_partition_fill.html b/spec/fixtures/layout_partition_fill.html
new file mode 100644
index 0000000..d77b1f7
--- /dev/null
+++ b/spec/fixtures/layout_partition_fill.html
@@ -0,0 +1,40 @@
+<html>
+  <head>
+    <title>Test: Layout Partition</title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+  </head>
+  <body>
+  <h1>Test: Layout Partition</h1>
+    <script type="text/javascript">
+color=pv.Colors.category19()
+w=400
+h=400
+
+subtree={a:1,b:2,c:3,d:4}
+
+hier_nodes=pv.dom({a:subtree,b:subtree, c:subtree, d:subtree,e:subtree,f:subtree}).root("test").nodes()
+
+
+vis = new pv.Panel()
+    .width(w)
+    .height(h)
+    .top(20)
+    .bottom(10)
+    .left(10)
+
+partition= vis.add(pv.Layout.Partition.Fill).
+  nodes(hier_nodes).orient("left").
+  size(function(d) {return d.nodeValue})
+
+partition.node.add(pv.Bar).
+  fillStyle(function(d) {return color(d.nodeValue);}).
+  strokeStyle("black").
+  lineWidth(1).
+  antialias(false)
+  
+partition.label.add(pv.Label).
+text(function(d) {return d.nodeName})
+vis.render()
+</script>
+    </body>
+    </html>
\ No newline at end of file
diff --git a/spec/fixtures/layout_partition_fill.svg b/spec/fixtures/layout_partition_fill.svg
new file mode 100644
index 0000000..f02b664
--- /dev/null
+++ b/spec/fixtures/layout_partition_fill.svg
@@ -0,0 +1,32 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="410" height="430"><g transform="translate(10, 20)"><g><rect shape-rendering="crispEdges" width="133.33333333333331" height="400" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width="1"/><rect shape-rendering="crispEdges" x="133.33333333333331" width="133.33333333333331" height="66.66666666666666" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width="1"/><rect shape-rendering="crisp [...]
+<text pointer-events="none" dy="0.35em" transform="translate(66.6667, 200)" fill="rgb(0,0,0)" text-anchor="middle">test</text>
+<text pointer-events="none" dy="0.35em" transform="translate(200, 33.3333)" fill="rgb(0,0,0)" text-anchor="middle">a</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 3.33333)" fill="rgb(0,0,0)" text-anchor="middle">a</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 13.3333)" fill="rgb(0,0,0)" text-anchor="middle">b</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 30)" fill="rgb(0,0,0)" text-anchor="middle">c</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 53.3333)" fill="rgb(0,0,0)" text-anchor="middle">d</text>
+<text pointer-events="none" dy="0.35em" transform="translate(200, 100)" fill="rgb(0,0,0)" text-anchor="middle">b</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 70)" fill="rgb(0,0,0)" text-anchor="middle">a</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 80)" fill="rgb(0,0,0)" text-anchor="middle">b</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 96.6667)" fill="rgb(0,0,0)" text-anchor="middle">c</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 120)" fill="rgb(0,0,0)" text-anchor="middle">d</text>
+<text pointer-events="none" dy="0.35em" transform="translate(200, 166.667)" fill="rgb(0,0,0)" text-anchor="middle">c</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 136.667)" fill="rgb(0,0,0)" text-anchor="middle">a</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 146.667)" fill="rgb(0,0,0)" text-anchor="middle">b</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 163.333)" fill="rgb(0,0,0)" text-anchor="middle">c</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 186.667)" fill="rgb(0,0,0)" text-anchor="middle">d</text>
+<text pointer-events="none" dy="0.35em" transform="translate(200, 233.333)" fill="rgb(0,0,0)" text-anchor="middle">d</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 203.333)" fill="rgb(0,0,0)" text-anchor="middle">a</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 213.333)" fill="rgb(0,0,0)" text-anchor="middle">b</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 230)" fill="rgb(0,0,0)" text-anchor="middle">c</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 253.333)" fill="rgb(0,0,0)" text-anchor="middle">d</text>
+<text pointer-events="none" dy="0.35em" transform="translate(200, 300)" fill="rgb(0,0,0)" text-anchor="middle">e</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 270)" fill="rgb(0,0,0)" text-anchor="middle">a</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 280)" fill="rgb(0,0,0)" text-anchor="middle">b</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 296.667)" fill="rgb(0,0,0)" text-anchor="middle">c</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 320)" fill="rgb(0,0,0)" text-anchor="middle">d</text>
+<text pointer-events="none" dy="0.35em" transform="translate(200, 366.667)" fill="rgb(0,0,0)" text-anchor="middle">f</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 336.667)" fill="rgb(0,0,0)" text-anchor="middle">a</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 346.667)" fill="rgb(0,0,0)" text-anchor="middle">b</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 363.333)" fill="rgb(0,0,0)" text-anchor="middle">c</text>
+<text pointer-events="none" dy="0.35em" transform="translate(333.333, 386.667)" fill="rgb(0,0,0)" text-anchor="middle">d</text></g></g></svg>
diff --git a/spec/fixtures/layout_tree_orient_left.html b/spec/fixtures/layout_tree_orient_left.html
new file mode 100644
index 0000000..0ab86df
--- /dev/null
+++ b/spec/fixtures/layout_tree_orient_left.html
@@ -0,0 +1,36 @@
+<html>
+  <head>
+    <title>Test: Layout tree, orient left</title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+  </head>
+  <body>
+  <h1>Test: Layout tree, orient left</h1>
+    <script type="text/javascript">
+color=pv.Colors.category19()
+w=200
+h=200
+hier_nodes=pv.dom({a:1,b:{ba:2,bb:{bba:3}, bc:4}, c:5}).root("test").nodes()
+
+
+vis = new pv.Panel()
+    .width(w)
+    .height(h)
+    .top(20)
+    .bottom(10)
+    .left(10)
+
+treemap = vis.add(pv.Layout.Tree).
+  nodes(hier_nodes) .breadth(40).orient("left")
+
+treemap.node.add(pv.Dot).
+  fillStyle(function(d) {return color(d.nodeValue);}).
+  strokeStyle("black").
+  lineWidth(1).
+  antialias(false)
+treemap.link.add(pv.Line)  
+treemap.label.add(pv.Label).
+text(function(d) {return d.nodeName})
+vis.render()
+</script>
+    </body>
+    </html>
\ No newline at end of file
diff --git a/spec/fixtures/layout_tree_orient_left.svg b/spec/fixtures/layout_tree_orient_left.svg
new file mode 100644
index 0000000..c724530
--- /dev/null
+++ b/spec/fixtures/layout_tree_orient_left.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="210" height="230"><g transform="translate(10, 20)"><g><circle shape-rendering="crispEdges" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width="1" cx="0" cy="100" r="4.5"/><circle shape-rendering="crispEdges" fill="rgb(115,117,181)" stroke="rgb(0,0,0)" stroke-width="1" cx="60" cy="60" r="4.5"/><circle shape-rendering="crispEdges" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width [...]
diff --git a/spec/fixtures/layout_tree_orient_radial_breadth_20.html b/spec/fixtures/layout_tree_orient_radial_breadth_20.html
new file mode 100644
index 0000000..e29928e
--- /dev/null
+++ b/spec/fixtures/layout_tree_orient_radial_breadth_20.html
@@ -0,0 +1,39 @@
+<html>
+  <head>
+    <title>Test: Layout tree, orient radial</title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+  </head>
+  <body>
+  <h1>Test: Layout tree, orient radial</h1>
+    <script type="text/javascript">
+color=pv.Colors.category19()
+w=200
+h=200
+
+subtree={a:1,b:2,c:3,d:4}
+
+hier_nodes=pv.dom({a:subtree,b:subtree, c:subtree, d:subtree,e:subtree,f:subtree}).root("test").nodes()
+
+
+vis = new pv.Panel()
+    .width(w)
+    .height(h)
+    .top(20)
+    .bottom(10)
+    .left(10)
+
+treemap = vis.add(pv.Layout.Tree).
+  nodes(hier_nodes) .breadth(20).orient("radial")
+
+treemap.node.add(pv.Dot).
+  fillStyle(function(d) {return color(d.nodeValue);}).
+  strokeStyle("black").
+  lineWidth(1).
+  antialias(false)
+treemap.link.add(pv.Line)  
+treemap.label.add(pv.Label).
+text(function(d) {return d.nodeName})
+vis.render()
+</script>
+    </body>
+    </html>
\ No newline at end of file
diff --git a/spec/fixtures/layout_tree_orient_radial_breadth_20.svg b/spec/fixtures/layout_tree_orient_radial_breadth_20.svg
new file mode 100644
index 0000000..4e592fd
--- /dev/null
+++ b/spec/fixtures/layout_tree_orient_radial_breadth_20.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="210" height="230"><g transform="translate(10, 20)"><g><circle shape-rendering="crispEdges" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width="1" cx="100" cy="100" r="4.5"/><circle shape-rendering="crispEdges" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width="1" cx="70.57661008130299" cy="47.709808513524074" r="4.5"/><circle shape-rendering="crispEdges" fill="rgb(115,117,181)" [...]
diff --git a/spec/fixtures/layout_tree_orient_top.svg b/spec/fixtures/layout_tree_orient_top.svg
new file mode 100644
index 0000000..39b993b
--- /dev/null
+++ b/spec/fixtures/layout_tree_orient_top.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="210" height="230"><g transform="translate(10, 20)"><g><circle shape-rendering="crispEdges" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width="1" cx="100" cy="0" r="4.5"/><circle shape-rendering="crispEdges" fill="rgb(115,117,181)" stroke="rgb(0,0,0)" stroke-width="1" cx="60" cy="60" r="4.5"/><circle shape-rendering="crispEdges" fill="rgb(156,158,222)" stroke="rgb(0,0,0)" stroke-width [...]
diff --git a/spec/fixtures/layout_treemap.svg b/spec/fixtures/layout_treemap.svg
new file mode 100644
index 0000000..202b564
--- /dev/null
+++ b/spec/fixtures/layout_treemap.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="200" height="200"><g><g><rect shape-rendering="crispEdges" x="166.66666666666666" y="120" width="33.33333333333334" height="80" fill="rgb(156,158,222)"/><rect shape-rendering="crispEdges" x="166.66666666666666" y="120" width="33.33333333333334" height="80" stroke="rgb(0,0,0)" stroke-width="1"/><rect shape-rendering="crispEdges" x="88.88888888888889" y="72" width="111.11111111111111" height= [...]
diff --git a/spec/fixtures/line_interpolation.html b/spec/fixtures/line_interpolation.html
new file mode 100644
index 0000000..4de2b30
--- /dev/null
+++ b/spec/fixtures/line_interpolation.html
@@ -0,0 +1,63 @@
+<html>
+  <head>
+    <title>Test: Line interpolation</title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+  </head>
+  <body>
+  <h1>Test: Line interpolation</h1>
+    <script type="text/javascript">
+
+data = pv.range(0, 10, 0.2).map(function(x) {
+  return {x:x, y:Math.sin(x) + 2};
+});
+
+
+p_w=200
+p_h=150
+w = 20+p_w*2
+h = 20+p_h*4
+
+x = pv.Scale.linear(data, function(d) {return d.x;}).range(0, p_w-30)
+
+
+y = pv.Scale.linear(data, function(d) {return d.y;}).range(0, p_h-20);
+
+interpolations=["linear","step-before","step-after","polar","polar-reverse", "basis", "cardinal"]
+
+vis = new pv.Panel()
+  .width(w)
+  .height(h)
+  .bottom(20)
+  .left(20)
+  .right(10)
+  .top(5)
+
+for(var i=0; i<interpolations.length;i++) {
+var inter=interpolations[i];
+  n=i%2
+  m=Math.floor(i/2)
+  panel=vis.add(pv.Panel).
+  left(n*(p_w+10)).
+  top(m*(p_h+10)).
+  width(p_w).
+  height(p_h)
+  
+  panel.anchor('top').add(pv.Label).text(inter)
+  
+  panel.add(pv.Line).data(data).
+  lineWidth(2).
+  left(function(d){return x(d.x)}).
+  bottom(function(d){ return y(d.y)}).
+  interpolate(inter);
+  }
+  
+  
+     
+
+vis.render()
+
+
+
+</script>
+    </body>
+    </html>
\ No newline at end of file
diff --git a/spec/fixtures/line_interpolation.svg b/spec/fixtures/line_interpolation.svg
new file mode 100644
index 0000000..b48d555
--- /dev/null
+++ b/spec/fixtures/line_interpolation.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="450" height="645"><g transform="translate(20, 5)"><g><text pointer-events="none" y="3" dy="0.71em" transform="translate(100)" fill="rgb(0,0,0)" text-anchor="middle">linear</text></g><g><path d="M0,85.1110289025131L3.4693877551020407,72.16994632482216L6.938775510204081,59.74478387155618L10.408163265306124,48.330893559859334L13.877551020408163,38.38331117784524L17.346938775510203,30.298615443 [...]
diff --git a/spec/fixtures/line_interpolation_segmented.html b/spec/fixtures/line_interpolation_segmented.html
new file mode 100644
index 0000000..ff7383d
--- /dev/null
+++ b/spec/fixtures/line_interpolation_segmented.html
@@ -0,0 +1,65 @@
+<html>
+  <head>
+    <title>Test: Segmented line with interpolation </title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+  </head>
+  <body>
+  <h1>Test: Segmented line with interpolation</h1>
+    <script type="text/javascript">
+
+data = pv.range(0, 10, 0.2).map(function(x) {
+  return {x:x, y:Math.sin(x) + 2};
+});
+
+
+p_w=200
+p_h=150
+w = 20+p_w*2
+h = 20+p_h*4
+
+x = pv.Scale.linear(data, function(d) {return d.x;}).range(0, p_w-30)
+
+
+y = pv.Scale.linear(data, function(d) {return d.y;}).range(0, p_h-20);
+
+interpolations=["linear","step-before","step-after","polar","polar-reverse", "basis", "cardinal","monotone"]
+
+
+vis = new pv.Panel()
+  .width(w)
+  .height(h)
+  .bottom(20)
+  .left(20)
+  .right(10)
+  .top(5)
+
+for(var i=0; i<interpolations.length;i++) {
+var inter=interpolations[i];
+  n=i%2
+  m=Math.floor(i/2)
+  panel=vis.add(pv.Panel).
+  left(n*(p_w+10)).
+  top(m*(p_h+10)).
+  width(p_w).
+  height(p_h)
+  
+  panel.anchor('top').add(pv.Label).text(inter)
+  
+  panel.add(pv.Line).data(data).
+  segmented(true).
+  lineWidth(function(d) {return d.y * 2+this.index*0.5}).
+  left(function(d){return x(d.x)}).
+  bottom(function(d){ return y(d.y)}).
+  interpolate(inter);
+  }
+  
+  
+     
+
+vis.render()
+
+
+
+</script>
+    </body>
+    </html>
\ No newline at end of file
diff --git a/spec/fixtures/line_interpolation_segmented.svg b/spec/fixtures/line_interpolation_segmented.svg
new file mode 100644
index 0000000..ededee9
--- /dev/null
+++ b/spec/fixtures/line_interpolation_segmented.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="450" height="645"><g transform="translate(20, 5)"><g><text pointer-events="none" y="3" dy="0.71em" transform="translate(100)" fill="rgb(0,0,0)" text-anchor="middle">linear</text></g><g><path d="M1.9317831508337362,85.62892257707853L5.398489201794964,72.69784296163479 1.5402863084091165,71.64204968800954 -1.9317831508337362,84.59313522794767" fill="rgb(31,119,180)"/><path d="M5.8312535293567 [...]
diff --git a/spec/fixtures/protovis-r3.3.js b/spec/fixtures/protovis-r3.3.js
new file mode 100644
index 0000000..2130d5b
--- /dev/null
+++ b/spec/fixtures/protovis-r3.3.js
@@ -0,0 +1,287 @@
+// 3ec4c9b
+var a;if(!Array.prototype.map)Array.prototype.map=function(b,c){for(var d=this.length,f=new Array(d),g=0;g<d;g++)if(g in this)f[g]=b.call(c,this[g],g,this);return f};if(!Array.prototype.filter)Array.prototype.filter=function(b,c){for(var d=this.length,f=[],g=0;g<d;g++)if(g in this){var h=this[g];b.call(c,h,g,this)&&f.push(h)}return f};if(!Array.prototype.forEach)Array.prototype.forEach=function(b,c){for(var d=this.length>>>0,f=0;f<d;f++)f in this&&b.call(c,this[f],f,this)};
+if(!Array.prototype.reduce)Array.prototype.reduce=function(b,c){var d=this.length;if(!d&&arguments.length==1)throw new Error("reduce: empty array, no initial value");var f=0;if(arguments.length<2)for(;;){if(f in this){c=this[f++];break}if(++f>=d)throw new Error("reduce: no values, no initial value");}for(;f<d;f++)if(f in this)c=b(c,this[f],f,this);return c};var pv={};pv.version={major:3,minor:3};pv.identity=function(b){return b};pv.index=function(){return this.index};pv.child=function(){ [...]
+pv.parent=function(){return this.parent.index};pv.extend=function(b){function c(){}c.prototype=b.prototype||b;return new c};
+try{eval("pv.parse = function(x) x;")}catch(e){pv.parse=function(b){for(var c=new RegExp("function\\s*(\\b\\w+)?\\s*\\([^)]*\\)\\s*","mg"),d,f,g=0,h="";d=c.exec(b);){d=d.index+d[0].length;if(b.charAt(d)!="{"){h+=b.substring(g,d)+"{return ";g=d;for(var i=0;i>=0&&d<b.length;d++){var j=b.charAt(d);switch(j){case '"':case "'":for(;++d<b.length&&(f=b.charAt(d))!=j;)f=="\\"&&d++;break;case "[":case "(":i++;break;case "]":case ")":i--;break;case ";":case ",":i==0&&i--;break}}h+=pv.parse(b.subst [...]
+";}";g=d}c.lastIndex=d}h+=b.substring(g);return h}}pv.css=function(b,c){return window.getComputedStyle?window.getComputedStyle(b,null).getPropertyValue(c):b.currentStyle[c]};pv.error=function(b){typeof console=="undefined"?alert(b):console.error(b)};pv.listen=function(b,c,d){d=pv.listener(d);return b.addEventListener?b.addEventListener(c,d,false):b.attachEvent("on"+c,d)};pv.listener=function(b){return b.$listener||(b.$listener=function(c){try{pv.event=c;return b.call(this,c)}finally{dele [...]
+pv.ancestor=function(b,c){for(;c;){if(c==b)return true;c=c.parentNode}return false};pv.id=function(){var b=1;return function(){return b++}}();pv.functor=function(b){return typeof b=="function"?b:function(){return b}};pv.listen(window,"load",function(){for(pv.$={i:0,x:document.getElementsByTagName("script")};pv.$.i<pv.$.x.length;pv.$.i++){pv.$.s=pv.$.x[pv.$.i];if(pv.$.s.type=="text/javascript+protovis")try{window.eval(pv.parse(pv.$.s.text))}catch(b){pv.error(b)}}delete pv.$});pv.Format={};
+pv.Format.re=function(b){return b.replace(/[\\\^\$\*\+\?\[\]\(\)\.\{\}]/g,"\\$&")};pv.Format.pad=function(b,c,d){c=c-String(d).length;return c<1?d:(new Array(c+1)).join(b)+d};
+pv.Format.date=function(b){function c(f){return b.replace(/%[a-zA-Z0-9]/g,function(g){switch(g){case "%a":return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][f.getDay()];case "%A":return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][f.getDay()];case "%h":case "%b":return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][f.getMonth()];case "%B":return["January","February","March","April","May","June","July","August","September","October","Nov [...]
+case "%c":return f.toLocaleString();case "%C":return d("0",2,Math.floor(f.getFullYear()/100)%100);case "%d":return d("0",2,f.getDate());case "%x":case "%D":return d("0",2,f.getMonth()+1)+"/"+d("0",2,f.getDate())+"/"+d("0",2,f.getFullYear()%100);case "%e":return d(" ",2,f.getDate());case "%H":return d("0",2,f.getHours());case "%I":return(g=f.getHours()%12)?d("0",2,g):12;case "%m":return d("0",2,f.getMonth()+1);case "%M":return d("0",2,f.getMinutes());case "%n":return"\n";case "%p":return  [...]
+12?"AM":"PM";case "%T":case "%X":case "%r":g=f.getHours()%12;return(g?d("0",2,g):12)+":"+d("0",2,f.getMinutes())+":"+d("0",2,f.getSeconds())+" "+(f.getHours()<12?"AM":"PM");case "%R":return d("0",2,f.getHours())+":"+d("0",2,f.getMinutes());case "%S":return d("0",2,f.getSeconds());case "%Q":return d("0",3,f.getMilliseconds());case "%t":return"\t";case "%u":return(g=f.getDay())?g:1;case "%w":return f.getDay();case "%y":return d("0",2,f.getFullYear()%100);case "%Y":return f.getFullYear();ca [...]
+var d=pv.Format.pad;c.format=c;c.parse=function(f){var g=1970,h=0,i=1,j=0,k=0,l=0,s=[function(){}],p=pv.Format.re(b).replace(/%[a-zA-Z0-9]/g,function(q){switch(q){case "%b":s.push(function(m){h={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11}[m]});return"([A-Za-z]+)";case "%h":case "%B":s.push(function(m){h={January:0,February:1,March:2,April:3,May:4,June:5,July:6,August:7,September:8,October:9,November:10,December:11}[m]});return"([A-Za-z]+)";case "%e":case "% [...]
+m});return"([0-9]+)";case "%I":case "%H":s.push(function(m){j=m});return"([0-9]+)";case "%m":s.push(function(m){h=m-1});return"([0-9]+)";case "%M":s.push(function(m){k=m});return"([0-9]+)";case "%p":s.push(function(m){if(j==12){if(m=="am")j=0}else if(m=="pm")j=Number(j)+12});return"(am|pm)";case "%S":s.push(function(m){l=m});return"([0-9]+)";case "%y":s.push(function(m){m=Number(m);g=m+(0<=m&&m<69?2E3:m>=69&&m<100?1900:0)});return"([0-9]+)";case "%Y":s.push(function(m){g=m});return"([0-9 [...]
+return"%"}return q});(f=f.match(p))&&f.forEach(function(q,m){s[m](q)});return new Date(g,h,i,j,k,l)};return c};
+pv.Format.time=function(b){function c(f){f=Number(f);switch(b){case "short":if(f>=31536E6)return(f/31536E6).toFixed(1)+" years";else if(f>=6048E5)return(f/6048E5).toFixed(1)+" weeks";else if(f>=864E5)return(f/864E5).toFixed(1)+" days";else if(f>=36E5)return(f/36E5).toFixed(1)+" hours";else if(f>=6E4)return(f/6E4).toFixed(1)+" minutes";return(f/1E3).toFixed(1)+" seconds";case "long":var g=[],h=f%36E5/6E4>>0;g.push(d("0",2,f%6E4/1E3>>0));if(f>=36E5){var i=f%864E5/36E5>>0;g.push(d("0",2,h)) [...]
+2,i));g.push(Math.floor(f/864E5).toFixed())}else g.push(i.toFixed())}else g.push(h.toFixed());return g.reverse().join(":")}}var d=pv.Format.pad;c.format=c;c.parse=function(f){switch(b){case "short":for(var g=/([0-9,.]+)\s*([a-z]+)/g,h,i=0;h=g.exec(f);){var j=parseFloat(h[0].replace(",","")),k=0;switch(h[2].toLowerCase()){case "year":case "years":k=31536E6;break;case "week":case "weeks":k=6048E5;break;case "day":case "days":k=864E5;break;case "hour":case "hours":k=36E5;break;case "minute" [...]
+6E4;break;case "second":case "seconds":k=1E3;break}i+=j*k}return i;case "long":h=f.replace(",","").split(":").reverse();i=0;if(h.length)i+=parseFloat(h[0])*1E3;if(h.length>1)i+=parseFloat(h[1])*6E4;if(h.length>2)i+=parseFloat(h[2])*36E5;if(h.length>3)i+=parseFloat(h[3])*864E5;return i}};return c};
+pv.Format.number=function(){function b(n){if(Infinity>h)n=Math.round(n*i)/i;var r=String(Math.abs(n)).split("."),t=r[0];if(t.length>d)t=t.substring(t.length-d);if(l&&t.length<c)t=(new Array(c-t.length+1)).join(j)+t;if(t.length>3)t=t.replace(/\B(?=(?:\d{3})+(?!\d))/g,p);if(!l&&t.length<f)t=(new Array(f-t.length+1)).join(j)+t;r[0]=n<0?q+t+m:t;n=r[1]||"";if(n.length<g)r[1]=n+(new Array(g-n.length+1)).join(k);return r.join(s)}var c=0,d=Infinity,f=0,g=0,h=0,i=1,j="0",k="0",l=true,s=".",p=",", [...]
+m="";b.format=b;b.parse=function(n){var r=pv.Format.re;n=String(n).replace(new RegExp("^("+r(j)+")*"),"").replace(new RegExp("("+r(k)+")*$"),"").split(s);r=n[0].replace(new RegExp(r(p),"g"),"");if(r.length>d)r=r.substring(r.length-d);n=n[1]?Number("0."+n[1]):0;if(Infinity>h)n=Math.round(n*i)/i;return Math.round(r)+n};b.integerDigits=function(n,r){if(arguments.length){c=Number(n);d=arguments.length>1?Number(r):c;f=c+Math.floor(c/3)*p.length;return this}return[c,d]};b.fractionDigits=functi [...]
+Number(n);h=arguments.length>1?Number(r):g;i=Math.pow(10,h);return this}return[g,h]};b.integerPad=function(n){if(arguments.length){j=String(n);l=/\d/.test(j);return this}return j};b.fractionPad=function(n){if(arguments.length){k=String(n);return this}return k};b.decimal=function(n){if(arguments.length){s=String(n);return this}return s};b.group=function(n){if(arguments.length){p=n?String(n):"";f=c+Math.floor(c/3)*p.length;return this}return p};b.negativeAffix=function(n,r){if(arguments.le [...]
+"");m=String(r||"");return this}return[q,m]};return b};pv.map=function(b,c){var d={};return c?b.map(function(f,g){d.index=g;return c.call(d,f)}):b.slice()};pv.repeat=function(b,c){if(arguments.length==1)c=2;return pv.blend(pv.range(c).map(function(){return b}))};pv.cross=function(b,c){for(var d=[],f=0,g=b.length,h=c.length;f<g;f++)for(var i=0,j=b[f];i<h;i++)d.push([j,c[i]]);return d};pv.blend=function(b){return Array.prototype.concat.apply([],b)};
+pv.transpose=function(b){var c=b.length,d=pv.max(b,function(i){return i.length});if(d>c){b.length=d;for(var f=c;f<d;f++)b[f]=new Array(c);for(f=0;f<c;f++)for(var g=f+1;g<d;g++){var h=b[f][g];b[f][g]=b[g][f];b[g][f]=h}}else{for(f=0;f<d;f++)b[f].length=c;for(f=0;f<c;f++)for(g=0;g<f;g++){h=b[f][g];b[f][g]=b[g][f];b[g][f]=h}}b.length=d;for(f=0;f<d;f++)b[f].length=c;return b};pv.normalize=function(b,c){b=pv.map(b,c);c=pv.sum(b);for(var d=0;d<b.length;d++)b[d]/=c;return b};
+pv.permute=function(b,c,d){if(!d)d=pv.identity;var f=new Array(c.length),g={};c.forEach(function(h,i){g.index=h;f[i]=d.call(g,b[h])});return f};pv.numerate=function(b,c){if(!c)c=pv.identity;var d={},f={};b.forEach(function(g,h){f.index=h;d[c.call(f,g)]=h});return d};pv.uniq=function(b,c){if(!c)c=pv.identity;var d={},f=[],g={},h;b.forEach(function(i,j){g.index=j;h=c.call(g,i);h in d||(d[h]=f.push(h))});return f};pv.naturalOrder=function(b,c){return b<c?-1:b>c?1:0};
+pv.reverseOrder=function(b,c){return c<b?-1:c>b?1:0};pv.search=function(b,c,d){if(!d)d=pv.identity;for(var f=0,g=b.length-1;f<=g;){var h=f+g>>1,i=d(b[h]);if(i<c)f=h+1;else if(i>c)g=h-1;else return h}return-f-1};pv.search.index=function(b,c,d){b=pv.search(b,c,d);return b<0?-b-1:b};
+pv.range=function(b,c,d){if(arguments.length==1){c=b;b=0}if(d==undefined)d=1;if((c-b)/d==Infinity)throw new Error("range must be finite");var f=[],g=0,h;c-=(c-b)*1.0E-10;if(d<0)for(;(h=b+d*g++)>c;)f.push(h);else for(;(h=b+d*g++)<c;)f.push(h);return f};pv.random=function(b,c,d){if(arguments.length==1){c=b;b=0}if(d==undefined)d=1;return d?Math.floor(Math.random()*(c-b)/d)*d+b:Math.random()*(c-b)+b};
+pv.sum=function(b,c){var d={};return b.reduce(c?function(f,g,h){d.index=h;return f+c.call(d,g)}:function(f,g){return f+g},0)};pv.max=function(b,c){if(c==pv.index)return b.length-1;return Math.max.apply(null,c?pv.map(b,c):b)};pv.max.index=function(b,c){if(!b.length)return-1;if(c==pv.index)return b.length-1;if(!c)c=pv.identity;for(var d=0,f=-Infinity,g={},h=0;h<b.length;h++){g.index=h;var i=c.call(g,b[h]);if(i>f){f=i;d=h}}return d};
+pv.min=function(b,c){if(c==pv.index)return 0;return Math.min.apply(null,c?pv.map(b,c):b)};pv.min.index=function(b,c){if(!b.length)return-1;if(c==pv.index)return 0;if(!c)c=pv.identity;for(var d=0,f=Infinity,g={},h=0;h<b.length;h++){g.index=h;var i=c.call(g,b[h]);if(i<f){f=i;d=h}}return d};pv.mean=function(b,c){return pv.sum(b,c)/b.length};
+pv.median=function(b,c){if(c==pv.index)return(b.length-1)/2;b=pv.map(b,c).sort(pv.naturalOrder);if(b.length%2)return b[Math.floor(b.length/2)];c=b.length/2;return(b[c-1]+b[c])/2};pv.variance=function(b,c){if(b.length<1)return NaN;if(b.length==1)return 0;var d=pv.mean(b,c),f=0,g={};if(!c)c=pv.identity;for(var h=0;h<b.length;h++){g.index=h;var i=c.call(g,b[h])-d;f+=i*i}return f};pv.deviation=function(b,c){return Math.sqrt(pv.variance(b,c)/(b.length-1))};pv.log=function(b,c){return Math.log [...]
+pv.logSymmetric=function(b,c){return b==0?0:b<0?-pv.log(-b,c):pv.log(b,c)};pv.logAdjusted=function(b,c){if(!isFinite(b))return b;var d=b<0;if(b<c)b+=(c-b)/c;return d?-pv.log(b,c):pv.log(b,c)};pv.logFloor=function(b,c){return b>0?Math.pow(c,Math.floor(pv.log(b,c))):-Math.pow(c,-Math.floor(-pv.log(-b,c)))};pv.logCeil=function(b,c){return b>0?Math.pow(c,Math.ceil(pv.log(b,c))):-Math.pow(c,-Math.ceil(-pv.log(-b,c)))};
+(function(){var b=Math.PI/180,c=180/Math.PI;pv.radians=function(d){return b*d};pv.degrees=function(d){return c*d}})();pv.keys=function(b){var c=[];for(var d in b)c.push(d);return c};pv.entries=function(b){var c=[];for(var d in b)c.push({key:d,value:b[d]});return c};pv.values=function(b){var c=[];for(var d in b)c.push(b[d]);return c};pv.dict=function(b,c){for(var d={},f={},g=0;g<b.length;g++)if(g in b){var h=b[g];f.index=g;d[h]=c.call(f,h)}return d};pv.dom=function(b){return new pv.Dom(b)};
+pv.Dom=function(b){this.$map=b};pv.Dom.prototype.$leaf=function(b){return typeof b!="object"};pv.Dom.prototype.leaf=function(b){if(arguments.length){this.$leaf=b;return this}return this.$leaf};pv.Dom.prototype.root=function(b){function c(g){var h=new pv.Dom.Node;for(var i in g){var j=g[i];h.appendChild(d(j)?new pv.Dom.Node(j):c(j)).nodeName=i}return h}var d=this.$leaf,f=c(this.$map);f.nodeName=b;return f};pv.Dom.prototype.nodes=function(){return this.root().nodes()};
+pv.Dom.Node=function(b){this.nodeValue=b;this.childNodes=[]};a=pv.Dom.Node.prototype;a.parentNode=null;a.firstChild=null;a.lastChild=null;a.previousSibling=null;a.nextSibling=null;
+a.removeChild=function(b){var c=this.childNodes.indexOf(b);if(c==-1)throw new Error("child not found");this.childNodes.splice(c,1);if(b.previousSibling)b.previousSibling.nextSibling=b.nextSibling;else this.firstChild=b.nextSibling;if(b.nextSibling)b.nextSibling.previousSibling=b.previousSibling;else this.lastChild=b.previousSibling;delete b.nextSibling;delete b.previousSibling;delete b.parentNode;return b};
+a.appendChild=function(b){b.parentNode&&b.parentNode.removeChild(b);b.parentNode=this;if(b.previousSibling=this.lastChild)this.lastChild.nextSibling=b;else this.firstChild=b;this.lastChild=b;this.childNodes.push(b);return b};
+a.insertBefore=function(b,c){if(!c)return this.appendChild(b);var d=this.childNodes.indexOf(c);if(d==-1)throw new Error("child not found");b.parentNode&&b.parentNode.removeChild(b);b.parentNode=this;b.nextSibling=c;if(b.previousSibling=c.previousSibling)c.previousSibling.nextSibling=b;else{if(c==this.lastChild)this.lastChild=b;this.firstChild=b}this.childNodes.splice(d,0,b);return b};
+a.replaceChild=function(b,c){var d=this.childNodes.indexOf(c);if(d==-1)throw new Error("child not found");b.parentNode&&b.parentNode.removeChild(b);b.parentNode=this;b.nextSibling=c.nextSibling;if(b.previousSibling=c.previousSibling)c.previousSibling.nextSibling=b;else this.firstChild=b;if(c.nextSibling)c.nextSibling.previousSibling=b;else this.lastChild=b;this.childNodes[d]=b;return c};a.visitBefore=function(b){function c(d,f){b(d,f);for(d=d.firstChild;d;d=d.nextSibling)c(d,f+1)}c(this,0)};
+a.visitAfter=function(b){function c(d,f){for(var g=d.firstChild;g;g=g.nextSibling)c(g,f+1);b(d,f)}c(this,0)};a.sort=function(b){if(this.firstChild){this.childNodes.sort(b);var c=this.firstChild=this.childNodes[0],d;delete c.previousSibling;for(var f=1;f<this.childNodes.length;f++){c.sort(b);d=this.childNodes[f];d.previousSibling=c;c=c.nextSibling=d}this.lastChild=c;delete c.nextSibling;c.sort(b)}return this};
+a.reverse=function(){var b=[];this.visitAfter(function(c){for(;c.lastChild;)b.push(c.removeChild(c.lastChild));for(var d;d=b.pop();)c.insertBefore(d,c.firstChild)});return this};a.nodes=function(){function b(d){c.push(d);d.childNodes.forEach(b)}var c=[];b(this,c);return c};
+a.toggle=function(b){if(b)return this.toggled?this.visitBefore(function(d){d.toggled&&d.toggle()}):this.visitAfter(function(d){d.toggled||d.toggle()});b=this;if(b.toggled){for(var c;c=b.toggled.pop();)b.appendChild(c);delete b.toggled}else if(b.lastChild)for(b.toggled=[];b.lastChild;)b.toggled.push(b.removeChild(b.lastChild))};pv.nodes=function(b){for(var c=new pv.Dom.Node,d=0;d<b.length;d++)c.appendChild(new pv.Dom.Node(b[d]));return c.nodes()};pv.tree=function(b){return new pv.Tree(b)};
+pv.Tree=function(b){this.array=b};pv.Tree.prototype.keys=function(b){this.k=b;return this};pv.Tree.prototype.value=function(b){this.v=b;return this};pv.Tree.prototype.map=function(){for(var b={},c={},d=0;d<this.array.length;d++){c.index=d;for(var f=this.array[d],g=this.k.call(c,f),h=b,i=0;i<g.length-1;i++)h=h[g[i]]||(h[g[i]]={});h[g[i]]=this.v?this.v.call(c,f):f}return b};pv.nest=function(b){return new pv.Nest(b)};pv.Nest=function(b){this.array=b;this.keys=[]};a=pv.Nest.prototype;
+a.key=function(b){this.keys.push(b);return this};a.sortKeys=function(b){this.keys[this.keys.length-1].order=b||pv.naturalOrder;return this};a.sortValues=function(b){this.order=b||pv.naturalOrder;return this};a.map=function(){for(var b={},c=[],d,f=0;f<this.array.length;f++){var g=this.array[f],h=b;for(d=0;d<this.keys.length-1;d++){var i=this.keys[d](g);h[i]||(h[i]={});h=h[i]}i=this.keys[d](g);if(!h[i]){d=[];c.push(d);h[i]=d}h[i].push(g)}if(this.order)for(d=0;d<c.length;d++)c[d].sort(this. [...]
+a.entries=function(){function b(d){var f=[];for(var g in d){var h=d[g];f.push({key:g,values:h instanceof Array?h:b(h)})}return f}function c(d,f){var g=this.keys[f].order;g&&d.sort(function(i,j){return g(i.key,j.key)});if(++f<this.keys.length)for(var h=0;h<d.length;h++)c.call(this,d[h].values,f);return d}return c.call(this,b(this.map()),0)};a.rollup=function(b){function c(d){for(var f in d){var g=d[f];if(g instanceof Array)d[f]=b(g);else c(g)}return d}return c(this.map())};pv.flatten=func [...]
+pv.Flatten=function(b){this.map=b;this.keys=[]};pv.Flatten.prototype.key=function(b,c){this.keys.push({name:b,value:c});delete this.$leaf;return this};pv.Flatten.prototype.leaf=function(b){this.keys.length=0;this.$leaf=b;return this};
+pv.Flatten.prototype.array=function(){function b(i,j){if(j<f.length-1)for(var k in i){d.push(k);b(i[k],j+1);d.pop()}else c.push(d.concat(i))}var c=[],d=[],f=this.keys,g=this.$leaf;if(g){function h(i,j){if(g(i))c.push({keys:d.slice(),value:i});else for(var k in i){d.push(k);h(i[k],j+1);d.pop()}}h(this.map,0);return c}b(this.map,0);return c.map(function(i){for(var j={},k=0;k<f.length;k++){var l=f[k],s=i[k];j[l.name]=l.value?l.value.call(null,s):s}return j})};
+pv.vector=function(b,c){return new pv.Vector(b,c)};pv.Vector=function(b,c){this.x=b;this.y=c};a=pv.Vector.prototype;a.perp=function(){return new pv.Vector(-this.y,this.x)};a.norm=function(){var b=this.length();return this.times(b?1/b:1)};a.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};a.times=function(b){return new pv.Vector(this.x*b,this.y*b)};a.plus=function(b,c){return arguments.length==1?new pv.Vector(this.x+b.x,this.y+b.y):new pv.Vector(this.x+b,this.y+c)};
+a.minus=function(b,c){return arguments.length==1?new pv.Vector(this.x-b.x,this.y-b.y):new pv.Vector(this.x-b,this.y-c)};a.dot=function(b,c){return arguments.length==1?this.x*b.x+this.y*b.y:this.x*b+this.y*c};pv.Transform=function(){};pv.Transform.prototype={k:1,x:0,y:0};pv.Transform.identity=new pv.Transform;pv.Transform.prototype.translate=function(b,c){var d=new pv.Transform;d.k=this.k;d.x=this.k*b+this.x;d.y=this.k*c+this.y;return d};
+pv.Transform.prototype.scale=function(b){var c=new pv.Transform;c.k=this.k*b;c.x=this.x;c.y=this.y;return c};pv.Transform.prototype.invert=function(){var b=new pv.Transform,c=1/this.k;b.k=c;b.x=-this.x*c;b.y=-this.y*c;return b};pv.Transform.prototype.times=function(b){var c=new pv.Transform;c.k=this.k*b.k;c.x=this.k*b.x+this.x;c.y=this.k*b.y+this.y;return c};pv.Scale=function(){};
+pv.Scale.interpolator=function(b,c){if(typeof b=="number")return function(d){return d*(c-b)+b};b=pv.color(b).rgb();c=pv.color(c).rgb();return function(d){var f=b.a*(1-d)+c.a*d;if(f<1.0E-5)f=0;return b.a==0?pv.rgb(c.r,c.g,c.b,f):c.a==0?pv.rgb(b.r,b.g,b.b,f):pv.rgb(Math.round(b.r*(1-d)+c.r*d),Math.round(b.g*(1-d)+c.g*d),Math.round(b.b*(1-d)+c.b*d),f)}};
+pv.Scale.quantitative=function(){function b(p){return new Date(p)}function c(p){var q=pv.search(d,p);if(q<0)q=-q-2;q=Math.max(0,Math.min(h.length-1,q));return h[q]((k(p)-f[q])/(f[q+1]-f[q]))}var d=[0,1],f=[0,1],g=[0,1],h=[pv.identity],i=Number,j=false,k=pv.identity,l=pv.identity,s=String;c.transform=function(p,q){k=function(m){return j?-p(-m):p(m)};l=function(m){return j?-q(-m):q(m)};f=d.map(k);return this};c.domain=function(p,q,m){if(arguments.length){var n;if(p instanceof Array){if(arg [...]
+2)q=pv.identity;if(arguments.length<3)m=q;n=p.length&&q(p[0]);d=p.length?[pv.min(p,q),pv.max(p,m)]:[]}else{n=p;d=Array.prototype.slice.call(arguments).map(Number)}if(d.length){if(d.length==1)d=[d[0],d[0]]}else d=[-Infinity,Infinity];j=(d[0]||d[d.length-1])<0;f=d.map(k);i=n instanceof Date?b:Number;return this}return d.map(i)};c.range=function(){if(arguments.length){g=Array.prototype.slice.call(arguments);if(g.length){if(g.length==1)g=[g[0],g[0]]}else g=[-Infinity,Infinity];h=[];for(var p [...]
+1;p++)h.push(pv.Scale.interpolator(g[p],g[p+1]));return this}return g};c.invert=function(p){var q=pv.search(g,p);if(q<0)q=-q-2;q=Math.max(0,Math.min(h.length-1,q));return i(l(f[q]+(p-g[q])/(g[q+1]-g[q])*(f[q+1]-f[q])))};c.ticks=function(p){var q=d[0],m=d[d.length-1],n=m<q,r=n?m:q;m=n?q:m;var t=m-r;if(!t||!isFinite(t)){if(i==b)s=pv.Format.date("%x");return[i(r)]}if(i==b){function x(w,y){switch(y){case 31536E6:w.setMonth(0);case 2592E6:w.setDate(1);case 6048E5:y==6048E5&&w.setDate(w.getDat [...]
+case 864E5:w.setHours(0);case 36E5:w.setMinutes(0);case 6E4:w.setSeconds(0);case 1E3:w.setMilliseconds(0)}}var u,o,v=1;if(t>=94608E6){q=31536E6;u="%Y";o=function(w){w.setFullYear(w.getFullYear()+v)}}else if(t>=7776E6){q=2592E6;u="%m/%Y";o=function(w){w.setMonth(w.getMonth()+v)}}else if(t>=18144E5){q=6048E5;u="%m/%d";o=function(w){w.setDate(w.getDate()+7*v)}}else if(t>=2592E5){q=864E5;u="%m/%d";o=function(w){w.setDate(w.getDate()+v)}}else if(t>=108E5){q=36E5;u="%I:%M %p";o=function(w){w.s [...]
+v)}}else if(t>=18E4){q=6E4;u="%I:%M %p";o=function(w){w.setMinutes(w.getMinutes()+v)}}else if(t>=3E3){q=1E3;u="%I:%M:%S";o=function(w){w.setSeconds(w.getSeconds()+v)}}else{q=1;u="%S.%Qs";o=function(w){w.setTime(w.getTime()+v)}}s=pv.Format.date(u);r=new Date(r);u=[];x(r,q);t=t/q;if(t>10)switch(q){case 36E5:v=t>20?6:3;r.setHours(Math.floor(r.getHours()/v)*v);break;case 2592E6:v=3;r.setMonth(Math.floor(r.getMonth()/v)*v);break;case 6E4:v=t>30?15:t>15?10:5;r.setMinutes(Math.floor(r.getMinute [...]
+break;case 1E3:v=t>90?15:t>60?10:5;r.setSeconds(Math.floor(r.getSeconds()/v)*v);break;case 1:v=t>1E3?250:t>200?100:t>100?50:t>50?25:5;r.setMilliseconds(Math.floor(r.getMilliseconds()/v)*v);break;default:v=pv.logCeil(t/15,10);if(t/v<2)v/=5;else if(t/v<5)v/=2;r.setFullYear(Math.floor(r.getFullYear()/v)*v);break}for(;;){o(r);if(r>m)break;u.push(new Date(r))}return n?u.reverse():u}arguments.length||(p=10);v=pv.logFloor(t/p,10);q=p/(t/v);if(q<=0.15)v*=10;else if(q<=0.35)v*=5;else if(q<=0.75)v [...]
+v)*v;m=Math.floor(m/v)*v;s=pv.Format.number().fractionDigits(Math.max(0,-Math.floor(pv.log(v,10)+0.01)));m=pv.range(q,m+v,v);return n?m.reverse():m};c.tickFormat=function(p){return s(p)};c.nice=function(){if(d.length!=2)return this;var p=d[0],q=d[d.length-1],m=q<p,n=m?q:p;p=m?p:q;q=p-n;if(!q||!isFinite(q))return this;q=Math.pow(10,Math.round(Math.log(q)/Math.log(10))-1);d=[Math.floor(n/q)*q,Math.ceil(p/q)*q];m&&d.reverse();f=d.map(k);return this};c.by=function(p){function q(){return c(p. [...]
+arguments))}for(var m in c)q[m]=c[m];return q};c.domain.apply(c,arguments);return c};pv.Scale.linear=function(){var b=pv.Scale.quantitative();b.domain.apply(b,arguments);return b};
+pv.Scale.log=function(){var b=pv.Scale.quantitative(1,10),c,d,f=function(h){return Math.log(h)/d},g=function(h){return Math.pow(c,h)};b.ticks=function(){var h=b.domain(),i=h[0]<0,j=Math.floor(i?-f(-h[0]):f(h[0])),k=Math.ceil(i?-f(-h[1]):f(h[1])),l=[];if(i)for(l.push(-g(-j));j++<k;)for(i=c-1;i>0;i--)l.push(-g(-j)*i);else{for(;j<k;j++)for(i=1;i<c;i++)l.push(g(j)*i);l.push(g(j))}for(j=0;l[j]<h[0];j++);for(k=l.length;l[k-1]>h[1];k--);return l.slice(j,k)};b.tickFormat=function(h){return h.toP [...]
+b.nice=function(){var h=b.domain();return b.domain(pv.logFloor(h[0],c),pv.logCeil(h[1],c))};b.base=function(h){if(arguments.length){c=Number(h);d=Math.log(c);b.transform(f,g);return this}return c};b.domain.apply(b,arguments);return b.base(10)};pv.Scale.root=function(){var b=pv.Scale.quantitative();b.power=function(c){if(arguments.length){var d=Number(c),f=1/d;b.transform(function(g){return Math.pow(g,f)},function(g){return Math.pow(g,d)});return this}return d};b.domain.apply(b,arguments) [...]
+pv.Scale.ordinal=function(){function b(g){g in d||(d[g]=c.push(g)-1);return f[d[g]%f.length]}var c=[],d={},f=[];b.domain=function(g,h){if(arguments.length){g=g instanceof Array?arguments.length>1?pv.map(g,h):g:Array.prototype.slice.call(arguments);c=[];for(var i={},j=0;j<g.length;j++){var k=g[j];if(!(k in i)){i[k]=true;c.push(k)}}d=pv.numerate(c);return this}return c};b.range=function(g,h){if(arguments.length){f=g instanceof Array?arguments.length>1?pv.map(g,h):g:Array.prototype.slice.ca [...]
+if(typeof f[0]=="string")f=f.map(pv.color);return this}return f};b.split=function(g,h){var i=(h-g)/this.domain().length;f=pv.range(g+i/2,h,i);return this};b.splitFlush=function(g,h){var i=this.domain().length,j=(h-g)/(i-1);f=i==1?[(g+h)/2]:pv.range(g,h+j/2,j);return this};b.splitBanded=function(g,h,i){if(arguments.length<3)i=1;if(i<0){var j=this.domain().length;j=(h-g- -i*j)/(j+1);f=pv.range(g+j,h,j-i);f.band=-i}else{j=(h-g)/(this.domain().length+(1-i));f=pv.range(g+j*(1-i),h,j);f.band=j [...]
+b.by=function(g){function h(){return b(g.apply(this,arguments))}for(var i in b)h[i]=b[i];return h};b.domain.apply(b,arguments);return b};
+pv.Scale.quantile=function(){function b(i){return h(Math.max(0,Math.min(d,pv.search.index(f,i)-1))/d)}var c=-1,d=-1,f=[],g=[],h=pv.Scale.linear();b.quantiles=function(i){if(arguments.length){c=Number(i);if(c<0){f=[g[0]].concat(g);d=g.length-1}else{f=[];f[0]=g[0];for(var j=1;j<=c;j++)f[j]=g[~~(j*(g.length-1)/c)];d=c-1}return this}return f};b.domain=function(i,j){if(arguments.length){g=i instanceof Array?pv.map(i,j):Array.prototype.slice.call(arguments);g.sort(pv.naturalOrder);b.quantiles( [...]
+b.range=function(){if(arguments.length){h.range.apply(h,arguments);return this}return h.range()};b.by=function(i){function j(){return b(i.apply(this,arguments))}for(var k in b)j[k]=b[k];return j};b.domain.apply(b,arguments);return b};
+pv.histogram=function(b,c){var d=true;return{bins:function(f){var g=pv.map(b,c),h=[];arguments.length||(f=pv.Scale.linear(g).ticks());for(var i=0;i<f.length-1;i++){var j=h[i]=[];j.x=f[i];j.dx=f[i+1]-f[i];j.y=0}for(i=0;i<g.length;i++){j=pv.search.index(f,g[i])-1;j=h[Math.max(0,Math.min(h.length-1,j))];j.y++;j.push(b[i])}if(!d)for(i=0;i<h.length;i++)h[i].y/=g.length;return h},frequency:function(f){if(arguments.length){d=Boolean(f);return this}return d}}};
+pv.color=function(b){if(b.rgb)return b.rgb();var c=/([a-z]+)\((.*)\)/i.exec(b);if(c){var d=c[2].split(","),f=1;switch(c[1]){case "hsla":case "rgba":f=parseFloat(d[3]);if(!f)return pv.Color.transparent;break}switch(c[1]){case "hsla":case "hsl":b=parseFloat(d[0]);var g=parseFloat(d[1])/100;d=parseFloat(d[2])/100;return(new pv.Color.Hsl(b,g,d,f)).rgb();case "rgba":case "rgb":function h(k){var l=parseFloat(k);return k[k.length-1]=="%"?Math.round(l*2.55):l}g=h(d[0]);var i=h(d[1]),j=h(d[2]);re [...]
+i,j,f)}}if(f=pv.Color.names[b])return f;if(b.charAt(0)=="#"){if(b.length==4){g=b.charAt(1);g+=g;i=b.charAt(2);i+=i;j=b.charAt(3);j+=j}else if(b.length==7){g=b.substring(1,3);i=b.substring(3,5);j=b.substring(5,7)}return pv.rgb(parseInt(g,16),parseInt(i,16),parseInt(j,16),1)}return new pv.Color(b,1)};pv.Color=function(b,c){this.color=b;this.opacity=c};pv.Color.prototype.brighter=function(b){return this.rgb().brighter(b)};pv.Color.prototype.darker=function(b){return this.rgb().darker(b)};
+pv.rgb=function(b,c,d,f){return new pv.Color.Rgb(b,c,d,arguments.length==4?f:1)};pv.Color.Rgb=function(b,c,d,f){pv.Color.call(this,f?"rgb("+b+","+c+","+d+")":"none",f);this.r=b;this.g=c;this.b=d;this.a=f};pv.Color.Rgb.prototype=pv.extend(pv.Color);a=pv.Color.Rgb.prototype;a.red=function(b){return pv.rgb(b,this.g,this.b,this.a)};a.green=function(b){return pv.rgb(this.r,b,this.b,this.a)};a.blue=function(b){return pv.rgb(this.r,this.g,b,this.a)};
+a.alpha=function(b){return pv.rgb(this.r,this.g,this.b,b)};a.rgb=function(){return this};a.brighter=function(b){b=Math.pow(0.7,arguments.length?b:1);var c=this.r,d=this.g,f=this.b;if(!c&&!d&&!f)return pv.rgb(30,30,30,this.a);if(c&&c<30)c=30;if(d&&d<30)d=30;if(f&&f<30)f=30;return pv.rgb(Math.min(255,Math.floor(c/b)),Math.min(255,Math.floor(d/b)),Math.min(255,Math.floor(f/b)),this.a)};
+a.darker=function(b){b=Math.pow(0.7,arguments.length?b:1);return pv.rgb(Math.max(0,Math.floor(b*this.r)),Math.max(0,Math.floor(b*this.g)),Math.max(0,Math.floor(b*this.b)),this.a)};pv.hsl=function(b,c,d,f){return new pv.Color.Hsl(b,c,d,arguments.length==4?f:1)};pv.Color.Hsl=function(b,c,d,f){pv.Color.call(this,"hsl("+b+","+c*100+"%,"+d*100+"%)",f);this.h=b;this.s=c;this.l=d;this.a=f};pv.Color.Hsl.prototype=pv.extend(pv.Color);a=pv.Color.Hsl.prototype;
+a.hue=function(b){return pv.hsl(b,this.s,this.l,this.a)};a.saturation=function(b){return pv.hsl(this.h,b,this.l,this.a)};a.lightness=function(b){return pv.hsl(this.h,this.s,b,this.a)};a.alpha=function(b){return pv.hsl(this.h,this.s,this.l,b)};
+a.rgb=function(){function b(j){if(j>360)j-=360;else if(j<0)j+=360;if(j<60)return i+(h-i)*j/60;if(j<180)return h;if(j<240)return i+(h-i)*(240-j)/60;return i}function c(j){return Math.round(b(j)*255)}var d=this.h,f=this.s,g=this.l;d%=360;if(d<0)d+=360;f=Math.max(0,Math.min(f,1));g=Math.max(0,Math.min(g,1));var h=g<=0.5?g*(1+f):g+f-g*f,i=2*g-h;return pv.rgb(c(d+120),c(d),c(d-120),this.a)};
+pv.Color.names={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9", [...]
+darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gains [...]
+ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lig [...]
+lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5 [...]
+moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460 [...]
+seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",transparent:pv.Color.transparent=pv.rgb(0,0,0,0)};(function(){var b=pv.Color.names;for(var c in b)b[c]=pv.color [...]
+pv.colors=function(){var b=pv.Scale.ordinal();b.range.apply(b,arguments);return b};pv.Colors={};pv.Colors.category10=function(){var b=pv.colors("#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf");b.domain.apply(b,arguments);return b};
+pv.Colors.category20=function(){var b=pv.colors("#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5");b.domain.apply(b,arguments);return b};
+pv.Colors.category19=function(){var b=pv.colors("#9c9ede","#7375b5","#4a5584","#cedb9c","#b5cf6b","#8ca252","#637939","#e7cb94","#e7ba52","#bd9e39","#8c6d31","#e7969c","#d6616b","#ad494a","#843c39","#de9ed6","#ce6dbd","#a55194","#7b4173");b.domain.apply(b,arguments);return b};pv.ramp=function(){var b=pv.Scale.linear();b.range.apply(b,arguments);return b};
+pv.Scene=pv.SvgScene={svg:"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/xmlns",xlink:"http://www.w3.org/1999/xlink",xhtml:"http://www.w3.org/1999/xhtml",scale:1,events:["DOMMouseScroll","mousewheel","mousedown","mouseup","mouseover","mouseout","mousemove","click","dblclick"],implicit:{svg:{"shape-rendering":"auto","pointer-events":"painted",x:0,y:0,dy:0,"text-anchor":"start",transform:"translate(0,0)",fill:"none","fill-opacity":1,stroke:"none","stroke-opacity":1,"stroke-widt [...]
+css:{font:"10px sans-serif"}}};pv.SvgScene.updateAll=function(b){if(b.length&&b[0].reverse&&b.type!="line"&&b.type!="area"){for(var c=pv.extend(b),d=0,f=b.length-1;f>=0;d++,f--)c[d]=b[f];b=c}this.removeSiblings(this[b.type](b))};pv.SvgScene.create=function(b){return document.createElementNS(this.svg,b)};
+pv.SvgScene.expect=function(b,c,d,f){if(b){if(b.tagName=="a")b=b.firstChild;if(b.tagName!=c){c=this.create(c);b.parentNode.replaceChild(c,b);b=c}}else b=this.create(c);for(var g in d){c=d[g];if(c==this.implicit.svg[g])c=null;c==null?b.removeAttribute(g):b.setAttribute(g,c)}for(g in f){c=f[g];if(c==this.implicit.css[g])c=null;if(c==null)b.style.removeProperty(g);else b.style[g]=c}return b};
+pv.SvgScene.append=function(b,c,d){b.$scene={scenes:c,index:d};b=this.title(b,c[d]);b.parentNode||c.$g.appendChild(b);return b.nextSibling};pv.SvgScene.title=function(b,c){var d=b.parentNode;if(d&&d.tagName!="a")d=null;if(c.title){if(!d){d=this.create("a");b.parentNode&&b.parentNode.replaceChild(d,b);d.appendChild(b)}d.setAttributeNS(this.xlink,"title",c.title);return d}d&&d.parentNode.replaceChild(b,d);return b};
+pv.SvgScene.dispatch=pv.listener(function(b){var c=b.target.$scene;if(c){var d=b.type;switch(d){case "DOMMouseScroll":d="mousewheel";b.wheel=-480*b.detail;break;case "mousewheel":b.wheel=(window.opera?12:1)*b.wheelDelta;break}pv.Mark.dispatch(d,c.scenes,c.index)&&b.preventDefault()}});pv.SvgScene.removeSiblings=function(b){for(;b;){var c=b.nextSibling;b.parentNode.removeChild(b);b=c}};pv.SvgScene.undefined=function(){};
+pv.SvgScene.pathBasis=function(){function b(f,g,h,i,j){return{x:f[0]*g.left+f[1]*h.left+f[2]*i.left+f[3]*j.left,y:f[0]*g.top+f[1]*h.top+f[2]*i.top+f[3]*j.top}}var c=[[1/6,2/3,1/6,0],[0,2/3,1/3,0],[0,1/3,2/3,0],[0,1/6,2/3,1/6]],d=function(f,g,h,i){var j=b(c[1],f,g,h,i),k=b(c[2],f,g,h,i);f=b(c[3],f,g,h,i);return"C"+j.x+","+j.y+","+k.x+","+k.y+","+f.x+","+f.y};d.segment=function(f,g,h,i){var j=b(c[0],f,g,h,i),k=b(c[1],f,g,h,i),l=b(c[2],f,g,h,i);f=b(c[3],f,g,h,i);return"M"+j.x+","+j.y+"C"+k. [...]
+","+l.x+","+l.y+","+f.x+","+f.y};return d}();pv.SvgScene.curveBasis=function(b){if(b.length<=2)return"";var c="",d=b[0],f=d,g=d,h=b[1];c+=this.pathBasis(d,f,g,h);for(var i=2;i<b.length;i++){d=f;f=g;g=h;h=b[i];c+=this.pathBasis(d,f,g,h)}c+=this.pathBasis(f,g,h,h);c+=this.pathBasis(g,h,h,h);return c};
+pv.SvgScene.curveBasisSegments=function(b){if(b.length<=2)return"";var c=[],d=b[0],f=d,g=d,h=b[1],i=this.pathBasis.segment(d,f,g,h);d=f;f=g;g=h;h=b[2];c.push(i+this.pathBasis(d,f,g,h));for(i=3;i<b.length;i++){d=f;f=g;g=h;h=b[i];c.push(this.pathBasis.segment(d,f,g,h))}c.push(this.pathBasis.segment(f,g,h,h)+this.pathBasis(g,h,h,h));return c};
+pv.SvgScene.curveHermite=function(b,c){if(c.length<1||b.length!=c.length&&b.length!=c.length+2)return"";var d=b.length!=c.length,f="",g=b[0],h=b[1],i=c[0],j=i,k=1;if(d){f+="Q"+(h.left-i.x*2/3)+","+(h.top-i.y*2/3)+","+h.left+","+h.top;g=b[1];k=2}if(c.length>1){j=c[1];h=b[k];k++;f+="C"+(g.left+i.x)+","+(g.top+i.y)+","+(h.left-j.x)+","+(h.top-j.y)+","+h.left+","+h.top;for(g=2;g<c.length;g++,k++){h=b[k];j=c[g];f+="S"+(h.left-j.x)+","+(h.top-j.y)+","+h.left+","+h.top}}if(d){b=b[k];f+="Q"+(h.l [...]
+3)+","+(h.top+j.y*2/3)+","+b.left+","+b.top}return f};
+pv.SvgScene.curveHermiteSegments=function(b,c){if(c.length<1||b.length!=c.length&&b.length!=c.length+2)return[];var d=b.length!=c.length,f=[],g=b[0],h=g,i=c[0],j=i,k=1;if(d){h=b[1];f.push("M"+g.left+","+g.top+"Q"+(h.left-j.x*2/3)+","+(h.top-j.y*2/3)+","+h.left+","+h.top);k=2}for(var l=1;l<c.length;l++,k++){g=h;i=j;h=b[k];j=c[l];f.push("M"+g.left+","+g.top+"C"+(g.left+i.x)+","+(g.top+i.y)+","+(h.left-j.x)+","+(h.top-j.y)+","+h.left+","+h.top)}if(d){b=b[k];f.push("M"+h.left+","+h.top+"Q"+( [...]
+2/3)+","+(h.top+j.y*2/3)+","+b.left+","+b.top)}return f};pv.SvgScene.cardinalTangents=function(b,c){var d=[];c=(1-c)/2;for(var f=b[0],g=b[1],h=b[2],i=3;i<b.length;i++){d.push({x:c*(h.left-f.left),y:c*(h.top-f.top)});f=g;g=h;h=b[i]}d.push({x:c*(h.left-f.left),y:c*(h.top-f.top)});return d};pv.SvgScene.curveCardinal=function(b,c){if(b.length<=2)return"";return this.curveHermite(b,this.cardinalTangents(b,c))};
+pv.SvgScene.curveCardinalSegments=function(b,c){if(b.length<=2)return"";return this.curveHermiteSegments(b,this.cardinalTangents(b,c))};
+pv.SvgScene.monotoneTangents=function(b){var c=[],d=[],f=[],g=[],h=0;for(h=0;h<b.length-1;h++)d[h]=(b[h+1].top-b[h].top)/(b[h+1].left-b[h].left);f[0]=d[0];g[0]=b[1].left-b[0].left;for(h=1;h<b.length-1;h++){f[h]=(d[h-1]+d[h])/2;g[h]=(b[h+1].left-b[h-1].left)/2}f[h]=d[h-1];g[h]=b[h].left-b[h-1].left;for(h=0;h<b.length-1;h++)if(d[h]==0){f[h]=0;f[h+1]=0}for(h=0;h<b.length-1;h++)if(!(Math.abs(f[h])<1.0E-5||Math.abs(f[h+1])<1.0E-5)){var i=f[h]/d[h],j=f[h+1]/d[h],k=i*i+j*j;if(k>9){k=3/Math.sqrt [...]
+k*i*d[h];f[h+1]=k*j*d[h]}}for(h=0;h<b.length;h++){d=1+f[h]*f[h];c.push({x:g[h]/3/d,y:f[h]*g[h]/3/d})}return c};pv.SvgScene.curveMonotone=function(b){if(b.length<=2)return"";return this.curveHermite(b,this.monotoneTangents(b))};pv.SvgScene.curveMonotoneSegments=function(b){if(b.length<=2)return"";return this.curveHermiteSegments(b,this.monotoneTangents(b))};
+pv.SvgScene.area=function(b){function c(p,q){for(var m=[],n=[],r=q;p<=r;p++,q--){var t=b[p],x=b[q];t=t.left+","+t.top;x=x.left+x.width+","+(x.top+x.height);if(p<r){var u=b[p+1],o=b[q-1];switch(g.interpolate){case "step-before":t+="V"+u.top;x+="H"+(o.left+o.width);break;case "step-after":t+="H"+u.left;x+="V"+(o.top+o.height);break}}m.push(t);n.push(x)}return m.concat(n).join("L")}function d(p,q){for(var m=[],n=[],r=q;p<=r;p++,q--){var t=b[q];m.push(b[p]);n.push({left:t.left+t.width,top:t. [...]
+"basis"){p=pv.SvgScene.curveBasis(m);q=pv.SvgScene.curveBasis(n)}else if(g.interpolate=="cardinal"){p=pv.SvgScene.curveCardinal(m,g.tension);q=pv.SvgScene.curveCardinal(n,g.tension)}else{p=pv.SvgScene.curveMonotone(m);q=pv.SvgScene.curveMonotone(n)}return m[0].left+","+m[0].top+p+"L"+n[0].left+","+n[0].top+q}var f=b.$g.firstChild;if(!b.length)return f;var g=b[0];if(g.segmented)return this.areaSegment(b);if(!g.visible)return f;var h=g.fillStyle,i=g.strokeStyle;if(!h.opacity&&!i.opacity)re [...]
+[],k,l=0;l<b.length;l++){k=b[l];if(k.width||k.height){for(var s=l+1;s<b.length;s++){k=b[s];if(!k.width&&!k.height)break}l&&g.interpolate!="step-after"&&l--;s<b.length&&g.interpolate!="step-before"&&s++;j.push((s-l>2&&(g.interpolate=="basis"||g.interpolate=="cardinal"||g.interpolate=="monotone")?d:c)(l,s-1));l=s-1}}if(!j.length)return f;f=this.expect(f,"path",{"shape-rendering":g.antialias?null:"crispEdges","pointer-events":g.events,cursor:g.cursor,d:"M"+j.join("ZM")+"Z",fill:h.color,"fil [...]
+null,stroke:i.color,"stroke-opacity":i.opacity||null,"stroke-width":i.opacity?g.lineWidth/this.scale:null});return this.append(f,b,0)};
+pv.SvgScene.areaSegment=function(b){var c=b.$g.firstChild,d=b[0],f,g;if(d.interpolate=="basis"||d.interpolate=="cardinal"||d.interpolate=="monotone"){f=[];g=[];for(var h=0,i=b.length;h<i;h++){var j=b[i-h-1];f.push(b[h]);g.push({left:j.left+j.width,top:j.top+j.height})}if(d.interpolate=="basis"){f=this.curveBasisSegments(f);g=this.curveBasisSegments(g)}else if(d.interpolate=="cardinal"){f=this.curveCardinalSegments(f,d.tension);g=this.curveCardinalSegments(g,d.tension)}else{f=this.curveMo [...]
+g=this.curveMonotoneSegments(g)}}h=0;for(i=b.length-1;h<i;h++){d=b[h];var k=b[h+1];if(d.visible&&k.visible){var l=d.fillStyle,s=d.strokeStyle;if(l.opacity||s.opacity){if(f){j=f[h];k="L"+g[i-h-1].substr(1);j=j+k+"Z"}else{var p=d;j=k;switch(d.interpolate){case "step-before":p=k;break;case "step-after":j=d;break}j="M"+d.left+","+p.top+"L"+k.left+","+j.top+"L"+(k.left+k.width)+","+(j.top+j.height)+"L"+(d.left+d.width)+","+(p.top+p.height)+"Z"}c=this.expect(c,"path",{"shape-rendering":d.antia [...]
+"crispEdges","pointer-events":d.events,cursor:d.cursor,d:j,fill:l.color,"fill-opacity":l.opacity||null,stroke:s.color,"stroke-opacity":s.opacity||null,"stroke-width":s.opacity?d.lineWidth/this.scale:null});c=this.append(c,b,h)}}}return c};
+pv.SvgScene.bar=function(b){for(var c=b.$g.firstChild,d=0;d<b.length;d++){var f=b[d];if(f.visible){var g=f.fillStyle,h=f.strokeStyle;if(g.opacity||h.opacity){c=this.expect(c,"rect",{"shape-rendering":f.antialias?null:"crispEdges","pointer-events":f.events,cursor:f.cursor,x:f.left,y:f.top,width:Math.max(1.0E-10,f.width),height:Math.max(1.0E-10,f.height),fill:g.color,"fill-opacity":g.opacity||null,stroke:h.color,"stroke-opacity":h.opacity||null,"stroke-width":h.opacity?f.lineWidth/this.sca [...]
+c=this.append(c,b,d)}}}return c};
+pv.SvgScene.dot=function(b){for(var c=b.$g.firstChild,d=0;d<b.length;d++){var f=b[d];if(f.visible){var g=f.fillStyle,h=f.strokeStyle;if(g.opacity||h.opacity){var i=f.shapeRadius,j=null;switch(f.shape){case "cross":j="M"+-i+","+-i+"L"+i+","+i+"M"+i+","+-i+"L"+-i+","+i;break;case "triangle":j=i;var k=i*1.1547;j="M0,"+j+"L"+k+","+-j+" "+-k+","+-j+"Z";break;case "diamond":i*=Math.SQRT2;j="M0,"+-i+"L"+i+",0 0,"+i+" "+-i+",0Z";break;case "square":j="M"+-i+","+-i+"L"+i+","+-i+" "+i+","+i+" "+-i [...]
+break;case "tick":j="M0,0L0,"+-f.shapeSize;break;case "bar":j="M0,"+f.shapeSize/2+"L0,"+-(f.shapeSize/2);break}g={"shape-rendering":f.antialias?null:"crispEdges","pointer-events":f.events,cursor:f.cursor,fill:g.color,"fill-opacity":g.opacity||null,stroke:h.color,"stroke-opacity":h.opacity||null,"stroke-width":h.opacity?f.lineWidth/this.scale:null};if(j){g.transform="translate("+f.left+","+f.top+")";if(f.shapeAngle)g.transform+=" rotate("+180*f.shapeAngle/Math.PI+")";g.d=j;c=this.expect(c [...]
+f.left;g.cy=f.top;g.r=i;c=this.expect(c,"circle",g)}c=this.append(c,b,d)}}}return c};
+pv.SvgScene.image=function(b){for(var c=b.$g.firstChild,d=0;d<b.length;d++){var f=b[d];if(f.visible){c=this.fill(c,b,d);if(f.image){c=this.expect(c,"foreignObject",{cursor:f.cursor,x:f.left,y:f.top,width:f.width,height:f.height});var g=c.firstChild||c.appendChild(document.createElementNS(this.xhtml,"canvas"));g.$scene={scenes:b,index:d};g.style.width=f.width;g.style.height=f.height;g.width=f.imageWidth;g.height=f.imageHeight;g.getContext("2d").putImageData(f.image,0,0)}else{c=this.expect [...]
+{preserveAspectRatio:"none",cursor:f.cursor,x:f.left,y:f.top,width:f.width,height:f.height});c.setAttributeNS(this.xlink,"href",f.url)}c=this.append(c,b,d);c=this.stroke(c,b,d)}}return c};
+pv.SvgScene.label=function(b){for(var c=b.$g.firstChild,d=0;d<b.length;d++){var f=b[d];if(f.visible){var g=f.textStyle;if(g.opacity&&f.text){var h=0,i=0,j=0,k="start";switch(f.textBaseline){case "middle":j=".35em";break;case "top":j=".71em";i=f.textMargin;break;case "bottom":i="-"+f.textMargin;break}switch(f.textAlign){case "right":k="end";h="-"+f.textMargin;break;case "center":k="middle";break;case "left":h=f.textMargin;break}c=this.expect(c,"text",{"pointer-events":f.events,cursor:f.cu [...]
+y:i,dy:j,transform:"translate("+f.left+","+f.top+")"+(f.textAngle?" rotate("+180*f.textAngle/Math.PI+")":"")+(this.scale!=1?" scale("+1/this.scale+")":""),fill:g.color,"fill-opacity":g.opacity||null,"text-anchor":k},{font:f.font,"text-shadow":f.textShadow,"text-decoration":f.textDecoration});if(c.firstChild)c.firstChild.nodeValue=f.text;else c.appendChild(document.createTextNode(f.text));c=this.append(c,b,d)}}}return c};
+pv.SvgScene.line=function(b){var c=b.$g.firstChild;if(b.length<2)return c;var d=b[0];if(d.segmented)return this.lineSegment(b);if(!d.visible)return c;var f=d.fillStyle,g=d.strokeStyle;if(!f.opacity&&!g.opacity)return c;var h="M"+d.left+","+d.top;if(b.length>2&&(d.interpolate=="basis"||d.interpolate=="cardinal"||d.interpolate=="monotone"))switch(d.interpolate){case "basis":h+=this.curveBasis(b);break;case "cardinal":h+=this.curveCardinal(b,d.tension);break;case "monotone":h+=this.curveMon [...]
+break}else for(var i=1;i<b.length;i++)h+=this.pathSegment(b[i-1],b[i]);c=this.expect(c,"path",{"shape-rendering":d.antialias?null:"crispEdges","pointer-events":d.events,cursor:d.cursor,d:h,fill:f.color,"fill-opacity":f.opacity||null,stroke:g.color,"stroke-opacity":g.opacity||null,"stroke-width":g.opacity?d.lineWidth/this.scale:null,"stroke-linejoin":d.lineJoin});return this.append(c,b,0)};
+pv.SvgScene.lineSegment=function(b){var c=b.$g.firstChild,d=b[0],f;switch(d.interpolate){case "basis":f=this.curveBasisSegments(b);break;case "cardinal":f=this.curveCardinalSegments(b,d.tension);break;case "monotone":f=this.curveMonotoneSegments(b);break}d=0;for(var g=b.length-1;d<g;d++){var h=b[d],i=b[d+1];if(h.visible&&i.visible){var j=h.strokeStyle,k=pv.Color.transparent;if(j.opacity){if(h.interpolate=="linear"&&h.lineJoin=="miter"){k=j;j=pv.Color.transparent;i=this.pathJoin(b[d-1],h, [...]
+f?f[d]:"M"+h.left+","+h.top+this.pathSegment(h,i);c=this.expect(c,"path",{"shape-rendering":h.antialias?null:"crispEdges","pointer-events":h.events,cursor:h.cursor,d:i,fill:k.color,"fill-opacity":k.opacity||null,stroke:j.color,"stroke-opacity":j.opacity||null,"stroke-width":j.opacity?h.lineWidth/this.scale:null,"stroke-linejoin":h.lineJoin});c=this.append(c,b,d)}}}return c};
+pv.SvgScene.pathSegment=function(b,c){var d=1;switch(b.interpolate){case "polar-reverse":d=0;case "polar":var f=c.left-b.left,g=c.top-b.top;b=1-b.eccentricity;f=Math.sqrt(f*f+g*g)/(2*b);if(b<=0||b>1)break;return"A"+f+","+f+" 0 0,"+d+" "+c.left+","+c.top;case "step-before":return"V"+c.top+"H"+c.left;case "step-after":return"H"+c.left+"V"+c.top}return"L"+c.left+","+c.top};pv.SvgScene.lineIntersect=function(b,c,d,f){return b.plus(c.times(d.minus(b).dot(f.perp())/c.dot(f.perp())))};
+pv.SvgScene.pathJoin=function(b,c,d,f){var g=pv.vector(c.left,c.top);d=pv.vector(d.left,d.top);var h=d.minus(g),i=h.perp().norm(),j=i.times(c.lineWidth/(2*this.scale));c=g.plus(j);var k=d.plus(j),l=d.minus(j);j=g.minus(j);if(b&&b.visible){b=g.minus(b.left,b.top).perp().norm().plus(i);j=this.lineIntersect(g,b,j,h);c=this.lineIntersect(g,b,c,h)}if(f&&f.visible){f=pv.vector(f.left,f.top).minus(d).perp().norm().plus(i);l=this.lineIntersect(d,f,l,h);k=this.lineIntersect(d,f,k,h)}return"M"+c.x [...]
+"L"+k.x+","+k.y+" "+l.x+","+l.y+" "+j.x+","+j.y};
+pv.SvgScene.panel=function(b){for(var c=b.$g,d=c&&c.firstChild,f=0;f<b.length;f++){var g=b[f];if(g.visible){if(!b.parent){g.canvas.style.display="inline-block";if(c&&c.parentNode!=g.canvas)d=(c=g.canvas.firstChild)&&c.firstChild;if(!c){c=g.canvas.appendChild(this.create("svg"));c.setAttribute("font-size","10px");c.setAttribute("font-family","sans-serif");c.setAttribute("fill","none");c.setAttribute("stroke","none");c.setAttribute("stroke-width",1.5);for(var h=0;h<this.events.length;h++)c [...]
+this.dispatch,false);d=c.firstChild}b.$g=c;c.setAttribute("width",g.width+g.left+g.right);c.setAttribute("height",g.height+g.top+g.bottom)}if(g.overflow=="hidden"){h=pv.id().toString(36);var i=this.expect(d,"g",{"clip-path":"url(#"+h+")"});i.parentNode||c.appendChild(i);b.$g=c=i;d=i.firstChild;d=this.expect(d,"clipPath",{id:h});h=d.firstChild||d.appendChild(this.create("rect"));h.setAttribute("x",g.left);h.setAttribute("y",g.top);h.setAttribute("width",g.width);h.setAttribute("height",g. [...]
+c.appendChild(d);d=d.nextSibling}d=this.fill(d,b,f);var j=this.scale,k=g.transform,l=g.left+k.x,s=g.top+k.y;this.scale*=k.k;for(h=0;h<g.children.length;h++){g.children[h].$g=d=this.expect(d,"g",{transform:"translate("+l+","+s+")"+(k.k!=1?" scale("+k.k+")":"")});this.updateAll(g.children[h]);d.parentNode||c.appendChild(d);d=d.nextSibling}this.scale=j;d=this.stroke(d,b,f);if(g.overflow=="hidden"){b.$g=c=i.parentNode;d=i.nextSibling}}}return d};
+pv.SvgScene.fill=function(b,c,d){var f=c[d],g=f.fillStyle;if(g.opacity||f.events=="all"){b=this.expect(b,"rect",{"shape-rendering":f.antialias?null:"crispEdges","pointer-events":f.events,cursor:f.cursor,x:f.left,y:f.top,width:f.width,height:f.height,fill:g.color,"fill-opacity":g.opacity,stroke:null});b=this.append(b,c,d)}return b};
+pv.SvgScene.stroke=function(b,c,d){var f=c[d],g=f.strokeStyle;if(g.opacity||f.events=="all"){b=this.expect(b,"rect",{"shape-rendering":f.antialias?null:"crispEdges","pointer-events":f.events=="all"?"stroke":f.events,cursor:f.cursor,x:f.left,y:f.top,width:Math.max(1.0E-10,f.width),height:Math.max(1.0E-10,f.height),fill:null,stroke:g.color,"stroke-opacity":g.opacity,"stroke-width":f.lineWidth/this.scale});b=this.append(b,c,d)}return b};
+pv.SvgScene.rule=function(b){for(var c=b.$g.firstChild,d=0;d<b.length;d++){var f=b[d];if(f.visible){var g=f.strokeStyle;if(g.opacity){c=this.expect(c,"line",{"shape-rendering":f.antialias?null:"crispEdges","pointer-events":f.events,cursor:f.cursor,x1:f.left,y1:f.top,x2:f.left+f.width,y2:f.top+f.height,stroke:g.color,"stroke-opacity":g.opacity,"stroke-width":f.lineWidth/this.scale});c=this.append(c,b,d)}}}return c};
+pv.SvgScene.wedge=function(b){for(var c=b.$g.firstChild,d=0;d<b.length;d++){var f=b[d];if(f.visible){var g=f.fillStyle,h=f.strokeStyle;if(g.opacity||h.opacity){var i=f.innerRadius,j=f.outerRadius,k=Math.abs(f.angle);if(k>=2*Math.PI)i=i?"M0,"+j+"A"+j+","+j+" 0 1,1 0,"+-j+"A"+j+","+j+" 0 1,1 0,"+j+"M0,"+i+"A"+i+","+i+" 0 1,1 0,"+-i+"A"+i+","+i+" 0 1,1 0,"+i+"Z":"M0,"+j+"A"+j+","+j+" 0 1,1 0,"+-j+"A"+j+","+j+" 0 1,1 0,"+j+"Z";else{var l=Math.min(f.startAngle,f.endAngle),s=Math.max(f.startAn [...]
+p=Math.cos(l),q=Math.cos(s);l=Math.sin(l);s=Math.sin(s);i=i?"M"+j*p+","+j*l+"A"+j+","+j+" 0 "+(k<Math.PI?"0":"1")+",1 "+j*q+","+j*s+"L"+i*q+","+i*s+"A"+i+","+i+" 0 "+(k<Math.PI?"0":"1")+",0 "+i*p+","+i*l+"Z":"M"+j*p+","+j*l+"A"+j+","+j+" 0 "+(k<Math.PI?"0":"1")+",1 "+j*q+","+j*s+"L0,0Z"}c=this.expect(c,"path",{"shape-rendering":f.antialias?null:"crispEdges","pointer-events":f.events,cursor:f.cursor,transform:"translate("+f.left+","+f.top+")",d:i,fill:g.color,"fill-rule":"evenodd","fill-o [...]
+null,stroke:h.color,"stroke-opacity":h.opacity||null,"stroke-width":h.opacity?f.lineWidth/this.scale:null});c=this.append(c,b,d)}}}return c};pv.Mark=function(){this.$properties=[];this.$handlers={}};pv.Mark.prototype.properties={};pv.Mark.cast={};pv.Mark.prototype.property=function(b,c){if(!this.hasOwnProperty("properties"))this.properties=pv.extend(this.properties);this.properties[b]=true;pv.Mark.prototype.propertyMethod(b,false,pv.Mark.cast[b]=c);return this};
+pv.Mark.prototype.propertyMethod=function(b,c,d){d||(d=pv.Mark.cast[b]);this[b]=function(f){if(c&&this.scene){var g=this.scene.defs;if(arguments.length){g[b]={id:f==null?0:pv.id(),value:f!=null&&d?d(f):f};return this}return g[b]?g[b].value:null}if(arguments.length){g=!c<<1|typeof f=="function";this.propertyValue(b,g&1&&d?function(){var h=f.apply(this,arguments);return h!=null?d(h):null}:f!=null&&d?d(f):f).type=g;return this}return this.instance()[b]}};
+pv.Mark.prototype.propertyValue=function(b,c){var d=this.$properties;c={name:b,id:pv.id(),value:c};for(var f=0;f<d.length;f++)if(d[f].name==b){d.splice(f,1);break}d.push(c);return c};pv.Mark.prototype.property("data").property("visible",Boolean).property("left",Number).property("right",Number).property("top",Number).property("bottom",Number).property("cursor",String).property("title",String).property("reverse",Boolean).property("antialias",Boolean).property("events",String).property("id" [...]
+a=pv.Mark.prototype;a.childIndex=-1;a.index=-1;a.scale=1;a.defaults=(new pv.Mark).data(function(b){return[b]}).visible(true).antialias(true).events("painted");a.extend=function(b){this.proto=b;this.target=b.target;return this};a.add=function(b){return this.parent.add(b).extend(this)};a.def=function(b,c){this.propertyMethod(b,true);return this[b](arguments.length>1?c:null)};
+a.anchor=function(b){b||(b="center");return(new pv.Anchor(this)).name(b).data(function(){return this.scene.target.map(function(c){return c.data})}).visible(function(){return this.scene.target[this.index].visible}).id(function(){return this.scene.target[this.index].id}).left(function(){var c=this.scene.target[this.index],d=c.width||0;switch(this.name()){case "bottom":case "top":case "center":return c.left+d/2;case "left":return null}return c.left+d}).top(function(){var c=this.scene.target [...]
+d=c.height||0;switch(this.name()){case "left":case "right":case "center":return c.top+d/2;case "top":return null}return c.top+d}).right(function(){var c=this.scene.target[this.index];return this.name()=="left"?c.right+(c.width||0):null}).bottom(function(){var c=this.scene.target[this.index];return this.name()=="top"?c.bottom+(c.height||0):null}).textAlign(function(){switch(this.name()){case "bottom":case "top":case "center":return"center";case "right":return"right"}return"left"}).textBas [...]
+case "top":return"top"}return"bottom"})};a.anchorTarget=function(){return this.target};a.margin=function(b){return this.left(b).right(b).top(b).bottom(b)};a.instance=function(b){var c=this.scene||this.parent.instance(-1).children[this.childIndex],d=!arguments.length||this.hasOwnProperty("index")?this.index:b;return c[d<0?c.length-1:d]};
+a.instances=function(b){for(var c=this,d=[],f;!(f=c.scene);){b=b.parent;d.push({index:b.index,childIndex:c.childIndex});c=c.parent}for(;d.length;){b=d.pop();f=f[b.index].children[b.childIndex]}if(this.hasOwnProperty("index")){d=pv.extend(f[this.index]);d.right=d.top=d.left=d.bottom=0;return[d]}return f};a.first=function(){return this.scene[0]};a.last=function(){return this.scene[this.scene.length-1]};a.sibling=function(){return this.index==0?null:this.scene[this.index-1]};
+a.cousin=function(){var b=this.parent;return(b=b&&b.sibling())&&b.children?b.children[this.childIndex][this.index]:null};
+a.render=function(){function b(i,j,k){i.scale=k;if(j<g.length){f.unshift(null);if(i.hasOwnProperty("index"))c(i,j,k);else{for(var l=0,s=i.scene.length;l<s;l++){i.index=l;c(i,j,k)}delete i.index}f.shift()}else{i.build();pv.Scene.scale=k;pv.Scene.updateAll(i.scene)}delete i.scale}function c(i,j,k){var l=i.scene[i.index],s;if(l.visible){var p=g[j],q=i.children[p];for(s=0;s<p;s++)i.children[s].scene=l.children[s];f[0]=l.data;if(q.scene)b(q,j+1,k*l.transform.k);else{q.scene=l.children[p];b(q, [...]
+delete q.scene}for(s=0;s<p;s++)delete i.children[s].scene}}var d=this.parent,f=pv.Mark.stack;if(d&&!this.root.scene)this.root.render();else{for(var g=[],h=this;h.parent;h=h.parent)g.unshift(h.childIndex);for(this.bind();d&&!d.hasOwnProperty("index");)d=d.parent;this.context(d?d.scene:undefined,d?d.index:-1,function(){b(this.root,0,1)})}};pv.Mark.stack=[];a=pv.Mark.prototype;
+a.bind=function(){function b(j){do for(var k=j.$properties,l=k.length-1;l>=0;l--){var s=k[l];if(!(s.name in c)){c[s.name]=s;switch(s.name){case "data":f=s;break;case "visible":case "id":g.push(s);break;default:d[s.type].push(s);break}}}while(j=j.proto)}var c={},d=[[],[],[],[]],f,g=[];b(this);b(this.defaults);d[1].reverse();d[3].reverse();var h=this;do for(var i in h.properties)i in c||d[2].push(c[i]={name:i,type:2,value:null});while(h=h.proto);h=d[0].concat(d[1]);for(i=0;i<h.length;i++)t [...]
+true);this.binds={properties:c,data:f,defs:h,required:g,optional:pv.blend(d)}};
+a.build=function(){var b=this.scene,c=pv.Mark.stack;if(!b){b=this.scene=[];b.mark=this;b.type=this.type;b.childIndex=this.childIndex;if(this.parent){b.parent=this.parent.scene;b.parentIndex=this.parent.index}}if(this.target)b.target=this.target.instances(b);if(this.binds.defs.length){var d=b.defs;if(!d)b.defs=d={};for(var f=0;f<this.binds.defs.length;f++){var g=this.binds.defs[f],h=d[g.name];if(!h||g.id>h.id)d[g.name]={id:0,value:g.type&1?g.value.apply(this,c):g.value}}}d=this.binds.data [...]
+1?d.value.apply(this,c):d.value;c.unshift(null);b.length=d.length;for(f=0;f<d.length;f++){pv.Mark.prototype.index=this.index=f;(g=b[f])||(b[f]=g={});g.data=c[0]=d[f];this.buildInstance(g)}pv.Mark.prototype.index=-1;delete this.index;c.shift();return this};a.buildProperties=function(b,c){for(var d=0,f=c.length;d<f;d++){var g=c[d],h=g.value;switch(g.type){case 0:case 1:h=this.scene.defs[g.name].value;break;case 3:h=h.apply(this,pv.Mark.stack);break}b[g.name]=h}};
+a.buildInstance=function(b){this.buildProperties(b,this.binds.required);if(b.visible){this.buildProperties(b,this.binds.optional);this.buildImplied(b)}};
+a.buildImplied=function(b){var c=b.left,d=b.right,f=b.top,g=b.bottom,h=this.properties,i=h.width?b.width:0,j=h.height?b.height:0,k=this.parent?this.parent.width():i+c+d;if(i==null)i=k-(d=d||0)-(c=c||0);else if(d==null)if(c==null)c=d=(k-i)/2;else d=k-i-c;else if(c==null)c=k-i-d;k=this.parent?this.parent.height():j+f+g;if(j==null)j=k-(f=f||0)-(g=g||0);else if(g==null)g=f==null?(f=(k-j)/2):k-j-f;else if(f==null)f=k-j-g;b.left=c;b.right=d;b.top=f;b.bottom=g;if(h.width)b.width=i;if(h.height)b [...]
+if(h.textStyle&&!b.textStyle)b.textStyle=pv.Color.transparent;if(h.fillStyle&&!b.fillStyle)b.fillStyle=pv.Color.transparent;if(h.strokeStyle&&!b.strokeStyle)b.strokeStyle=pv.Color.transparent};
+a.mouse=function(){var b=pv.event.pageX||0,c=pv.event.pageY||0,d=this.root.canvas();do{b-=d.offsetLeft;c-=d.offsetTop}while(d=d.offsetParent);d=pv.Transform.identity;var f=this.properties.transform?this:this.parent,g=[];do g.push(f);while(f=f.parent);for(;f=g.pop();)d=d.translate(f.left(),f.top()).times(f.transform());d=d.invert();return pv.vector(b*d.k+d.x,c*d.k+d.y)};a.event=function(b,c){this.$handlers[b]=pv.functor(c);return this};
+a.context=function(b,c,d){function f(l,s){pv.Mark.scene=l;h.index=s;if(l){var p=l.mark,q=p,m=[];do{m.push(q);i.push(l[s].data);q.index=s;q.scene=l;s=l.parentIndex;l=l.parent}while(q=q.parent);l=m.length-1;for(s=1;l>0;l--){q=m[l];q.scale=s;s*=q.scene[q.index].transform.k}if(p.children){l=0;for(m=p.children.length;l<m;l++){q=p.children[l];q.scene=p.scene[p.index].children[l];q.scale=s}}}}function g(l){if(l){l=l.mark;var s;if(l.children)for(var p=0,q=l.children.length;p<q;p++){s=l.children[ [...]
+delete s.scale}s=l;do{i.pop();if(s.parent){delete s.scene;delete s.scale}delete s.index}while(s=s.parent)}}var h=pv.Mark.prototype,i=pv.Mark.stack,j=pv.Mark.scene,k=h.index;g(j,k);f(b,c);try{d.apply(this,i)}finally{g(b,c);f(j,k)}};pv.Mark.dispatch=function(b,c,d){var f=c.mark,g=c.parent,h=f.$handlers[b];if(!h)return g&&pv.Mark.dispatch(b,g,c.parentIndex);f.context(c,d,function(){(f=h.apply(f,pv.Mark.stack))&&f.render&&f.render()});return true};pv.Mark.prototype.transition=function(){retu [...]
+pv.Mark.prototype.on=function(b){return this["$"+b]=new pv.Transient(this)};pv.Anchor=function(b){pv.Mark.call(this);this.target=b;this.parent=b.parent};pv.Anchor.prototype=pv.extend(pv.Mark).property("name",String);pv.Anchor.prototype.extend=function(b){this.proto=b;return this};pv.Area=function(){pv.Mark.call(this)};
+pv.Area.prototype=pv.extend(pv.Mark).property("width",Number).property("height",Number).property("lineWidth",Number).property("strokeStyle",pv.color).property("fillStyle",pv.color).property("segmented",Boolean).property("interpolate",String).property("tension",Number);pv.Area.prototype.type="area";pv.Area.prototype.defaults=(new pv.Area).extend(pv.Mark.prototype.defaults).lineWidth(1.5).fillStyle(pv.Colors.category20().by(pv.parent)).interpolate("linear").tension(0.7);
+pv.Area.prototype.buildImplied=function(b){if(b.height==null)b.height=0;if(b.width==null)b.width=0;pv.Mark.prototype.buildImplied.call(this,b)};pv.Area.fixed={lineWidth:1,lineJoin:1,strokeStyle:1,fillStyle:1,segmented:1,interpolate:1,tension:1};
+pv.Area.prototype.bind=function(){pv.Mark.prototype.bind.call(this);var b=this.binds,c=b.required;b=b.optional;for(var d=0,f=b.length;d<f;d++){var g=b[d];g.fixed=g.name in pv.Area.fixed;if(g.name=="segmented"){c.push(g);b.splice(d,1);d--;f--}}this.binds.$required=c;this.binds.$optional=b};
+pv.Area.prototype.buildInstance=function(b){var c=this.binds;if(this.index){var d=c.fixed;if(!d){d=c.fixed=[];function f(i){return!i.fixed||(d.push(i),false)}c.required=c.required.filter(f);if(!this.scene[0].segmented)c.optional=c.optional.filter(f)}c=0;for(var g=d.length;c<g;c++){var h=d[c].name;b[h]=this.scene[0][h]}}else{c.required=c.$required;c.optional=c.$optional;c.fixed=null}pv.Mark.prototype.buildInstance.call(this,b)};
+pv.Area.prototype.anchor=function(b){return pv.Mark.prototype.anchor.call(this,b).interpolate(function(){return this.scene.target[this.index].interpolate}).eccentricity(function(){return this.scene.target[this.index].eccentricity}).tension(function(){return this.scene.target[this.index].tension})};pv.Bar=function(){pv.Mark.call(this)};
+pv.Bar.prototype=pv.extend(pv.Mark).property("width",Number).property("height",Number).property("lineWidth",Number).property("strokeStyle",pv.color).property("fillStyle",pv.color);pv.Bar.prototype.type="bar";pv.Bar.prototype.defaults=(new pv.Bar).extend(pv.Mark.prototype.defaults).lineWidth(1.5).fillStyle(pv.Colors.category20().by(pv.parent));pv.Dot=function(){pv.Mark.call(this)};
+pv.Dot.prototype=pv.extend(pv.Mark).property("shape",String).property("shapeAngle",Number).property("shapeRadius",Number).property("shapeSize",Number).property("lineWidth",Number).property("strokeStyle",pv.color).property("fillStyle",pv.color);pv.Dot.prototype.type="dot";pv.Dot.prototype.defaults=(new pv.Dot).extend(pv.Mark.prototype.defaults).shape("circle").lineWidth(1.5).strokeStyle(pv.Colors.category10().by(pv.parent));
+pv.Dot.prototype.anchor=function(b){return pv.Mark.prototype.anchor.call(this,b).left(function(){var c=this.scene.target[this.index];switch(this.name()){case "bottom":case "top":case "center":return c.left;case "left":return null}return c.left+c.shapeRadius}).right(function(){var c=this.scene.target[this.index];return this.name()=="left"?c.right+c.shapeRadius:null}).top(function(){var c=this.scene.target[this.index];switch(this.name()){case "left":case "right":case "center":return c.top; [...]
+c.shapeRadius}).bottom(function(){var c=this.scene.target[this.index];return this.name()=="top"?c.bottom+c.shapeRadius:null}).textAlign(function(){switch(this.name()){case "left":return"right";case "bottom":case "top":case "center":return"center"}return"left"}).textBaseline(function(){switch(this.name()){case "right":case "left":case "center":return"middle";case "bottom":return"top"}return"bottom"})};
+pv.Dot.prototype.buildImplied=function(b){var c=b.shapeRadius,d=b.shapeSize;if(c==null)if(d==null){b.shapeSize=20.25;b.shapeRadius=4.5}else b.shapeRadius=Math.sqrt(d);else if(d==null)b.shapeSize=c*c;pv.Mark.prototype.buildImplied.call(this,b)};pv.Label=function(){pv.Mark.call(this)};
+pv.Label.prototype=pv.extend(pv.Mark).property("text",String).property("font",String).property("textAngle",Number).property("textStyle",pv.color).property("textAlign",String).property("textBaseline",String).property("textMargin",Number).property("textDecoration",String).property("textShadow",String);pv.Label.prototype.type="label";pv.Label.prototype.defaults=(new pv.Label).extend(pv.Mark.prototype.defaults).events("none").text(pv.identity).font("10px sans-serif").textAngle(0).textStyle(" [...]
+pv.Line=function(){pv.Mark.call(this)};pv.Line.prototype=pv.extend(pv.Mark).property("lineWidth",Number).property("lineJoin",String).property("strokeStyle",pv.color).property("fillStyle",pv.color).property("segmented",Boolean).property("interpolate",String).property("eccentricity",Number).property("tension",Number);a=pv.Line.prototype;a.type="line";a.defaults=(new pv.Line).extend(pv.Mark.prototype.defaults).lineJoin("miter").lineWidth(1.5).strokeStyle(pv.Colors.category10().by(pv.parent) [...]
+a.bind=pv.Area.prototype.bind;a.buildInstance=pv.Area.prototype.buildInstance;a.anchor=function(b){return pv.Area.prototype.anchor.call(this,b).textAlign(function(){switch(this.name()){case "left":return"right";case "bottom":case "top":case "center":return"center";case "right":return"left"}}).textBaseline(function(){switch(this.name()){case "right":case "left":case "center":return"middle";case "top":return"bottom";case "bottom":return"top"}})};pv.Rule=function(){pv.Mark.call(this)};
+pv.Rule.prototype=pv.extend(pv.Mark).property("width",Number).property("height",Number).property("lineWidth",Number).property("strokeStyle",pv.color);pv.Rule.prototype.type="rule";pv.Rule.prototype.defaults=(new pv.Rule).extend(pv.Mark.prototype.defaults).lineWidth(1).strokeStyle("black").antialias(false);pv.Rule.prototype.anchor=pv.Line.prototype.anchor;
+pv.Rule.prototype.buildImplied=function(b){var c=b.left,d=b.right;if(b.width!=null||c==null&&d==null||d!=null&&c!=null)b.height=0;else b.width=0;pv.Mark.prototype.buildImplied.call(this,b)};pv.Panel=function(){pv.Bar.call(this);this.children=[];this.root=this;this.$dom=pv.$&&pv.$.s};pv.Panel.prototype=pv.extend(pv.Bar).property("transform").property("overflow",String).property("canvas",function(b){return typeof b=="string"?document.getElementById(b):b});a=pv.Panel.prototype;a.type="panel";
+a.defaults=(new pv.Panel).extend(pv.Bar.prototype.defaults).fillStyle(null).overflow("visible");a.anchor=function(b){b=pv.Bar.prototype.anchor.call(this,b);b.parent=this;return b};a.add=function(b){b=new b;b.parent=this;b.root=this.root;b.childIndex=this.children.length;this.children.push(b);return b};a.bind=function(){pv.Mark.prototype.bind.call(this);for(var b=0;b<this.children.length;b++)this.children[b].bind()};
+a.buildInstance=function(b){pv.Bar.prototype.buildInstance.call(this,b);if(b.visible){if(!b.children)b.children=[];var c=this.scale*b.transform.k,d,f=this.children.length;pv.Mark.prototype.index=-1;for(var g=0;g<f;g++){d=this.children[g];d.scene=b.children[g];d.scale=c;d.build()}for(g=0;g<f;g++){d=this.children[g];b.children[g]=d.scene;delete d.scene;delete d.scale}b.children.length=f}};
+a.buildImplied=function(b){if(!this.parent){var c=b.canvas;if(c){if(c.$panel!=this)for(c.$panel=this;c.lastChild;)c.removeChild(c.lastChild);var d;if(b.width==null){d=parseFloat(pv.css(c,"width"));b.width=d-b.left-b.right}if(b.height==null){d=parseFloat(pv.css(c,"height"));b.height=d-b.top-b.bottom}}else{d=this.$canvas||(this.$canvas=[]);if(!(c=d[this.index])){c=d[this.index]=document.createElement("span");if(this.$dom)this.$dom.parentNode.insertBefore(c,this.$dom);else{for(d=document.bo [...]
+d.lastChild.tagName;)d=d.lastChild;if(d!=document.body)d=d.parentNode;d.appendChild(c)}}}b.canvas=c}if(!b.transform)b.transform=pv.Transform.identity;pv.Mark.prototype.buildImplied.call(this,b)};pv.Image=function(){pv.Bar.call(this)};pv.Image.prototype=pv.extend(pv.Bar).property("url",String).property("imageWidth",Number).property("imageHeight",Number);a=pv.Image.prototype;a.type="image";a.defaults=(new pv.Image).extend(pv.Bar.prototype.defaults).fillStyle(null);
+a.image=function(b){this.$image=function(){var c=b.apply(this,arguments);return c==null?pv.Color.transparent:typeof c=="string"?pv.color(c):c};return this};a.bind=function(){pv.Bar.prototype.bind.call(this);var b=this.binds,c=this;do b.image=c.$image;while(!b.image&&(c=c.proto))};
+a.buildImplied=function(b){pv.Bar.prototype.buildImplied.call(this,b);if(b.visible){if(b.imageWidth==null)b.imageWidth=b.width;if(b.imageHeight==null)b.imageHeight=b.height;if(b.url==null&&this.binds.image){var c=this.$canvas||(this.$canvas=document.createElement("canvas")),d=c.getContext("2d"),f=b.imageWidth,g=b.imageHeight,h=pv.Mark.stack;c.width=f;c.height=g;b=(b.image=d.createImageData(f,g)).data;h.unshift(null,null);for(d=c=0;c<g;c++){h[1]=c;for(var i=0;i<f;i++){h[0]=i;var j=this.bi [...]
+h);b[d++]=j.r;b[d++]=j.g;b[d++]=j.b;b[d++]=255*j.a}}h.splice(0,2)}}};pv.Wedge=function(){pv.Mark.call(this)};pv.Wedge.prototype=pv.extend(pv.Mark).property("startAngle",Number).property("endAngle",Number).property("angle",Number).property("innerRadius",Number).property("outerRadius",Number).property("lineWidth",Number).property("strokeStyle",pv.color).property("fillStyle",pv.color);a=pv.Wedge.prototype;a.type="wedge";
+a.defaults=(new pv.Wedge).extend(pv.Mark.prototype.defaults).startAngle(function(){var b=this.sibling();return b?b.endAngle:-Math.PI/2}).innerRadius(0).lineWidth(1.5).strokeStyle(null).fillStyle(pv.Colors.category20().by(pv.index));a.midRadius=function(){return(this.innerRadius()+this.outerRadius())/2};a.midAngle=function(){return(this.startAngle()+this.endAngle())/2};
+a.anchor=function(b){function c(g){return g.innerRadius||g.angle<2*Math.PI}function d(g){return(g.innerRadius+g.outerRadius)/2}function f(g){return(g.startAngle+g.endAngle)/2}return pv.Mark.prototype.anchor.call(this,b).left(function(){var g=this.scene.target[this.index];if(c(g))switch(this.name()){case "outer":return g.left+g.outerRadius*Math.cos(f(g));case "inner":return g.left+g.innerRadius*Math.cos(f(g));case "start":return g.left+d(g)*Math.cos(g.startAngle);case "center":return g.le [...]
+case "end":return g.left+d(g)*Math.cos(g.endAngle)}return g.left}).top(function(){var g=this.scene.target[this.index];if(c(g))switch(this.name()){case "outer":return g.top+g.outerRadius*Math.sin(f(g));case "inner":return g.top+g.innerRadius*Math.sin(f(g));case "start":return g.top+d(g)*Math.sin(g.startAngle);case "center":return g.top+d(g)*Math.sin(f(g));case "end":return g.top+d(g)*Math.sin(g.endAngle)}return g.top}).textAlign(function(){var g=this.scene.target[this.index];if(c(g))switc [...]
+"right":"left";case "inner":return pv.Wedge.upright(f(g))?"left":"right"}return"center"}).textBaseline(function(){var g=this.scene.target[this.index];if(c(g))switch(this.name()){case "start":return pv.Wedge.upright(g.startAngle)?"top":"bottom";case "end":return pv.Wedge.upright(g.endAngle)?"bottom":"top"}return"middle"}).textAngle(function(){var g=this.scene.target[this.index],h=0;if(c(g))switch(this.name()){case "center":case "inner":case "outer":h=f(g);break;case "start":h=g.startAngle [...]
+g.endAngle;break}return pv.Wedge.upright(h)?h:h+Math.PI})};pv.Wedge.upright=function(b){b%=2*Math.PI;b=b<0?2*Math.PI+b:b;return b<Math.PI/2||b>=3*Math.PI/2};pv.Wedge.prototype.buildImplied=function(b){if(b.angle==null)b.angle=b.endAngle-b.startAngle;else if(b.endAngle==null)b.endAngle=b.startAngle+b.angle;pv.Mark.prototype.buildImplied.call(this,b)};
+pv.Ease=function(){function b(n){return function(r){return 1-n(1-r)}}function c(n){return function(r){return 0.5*(r<0.5?n(2*r):2-n(2-2*r))}}function d(n){return function(r){return r<0?0:r>1?1:Math.pow(r,n)}}function f(n){return 1-Math.cos(n*Math.PI/2)}function g(n){return n?Math.pow(2,10*(n-1))-0.0010:0}function h(n){return-(Math.sqrt(1-n*n)-1)}function i(n,r){var t;r||(r=0.45);if(!n||n<1){n=1;t=r/4}else t=r/(2*Math.PI)*Math.asin(1/n);return function(x){return x<=0||x>=1?x:-(n*Math.pow(2 [...]
+Math.sin((x-t)*2*Math.PI/r))}}function j(n){n||(n=1.70158);return function(r){return r*r*((n+1)*r-n)}}function k(n){return n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+0.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+0.9375:7.5625*(n-=2.625/2.75)*n+0.984375}var l=d(2),s=d(3),p=i(),q=j(),m={linear:pv.identity,"quad-in":l,"quad-out":b(l),"quad-in-out":c(l),"quad-out-in":c(b(l)),"cubic-in":s,"cubic-out":b(s),"cubic-in-out":c(s),"cubic-out-in":c(b(s)),"sin-in":f,"sin-out":b(f),"sin-in-out":c(f [...]
+"exp-in":g,"exp-out":b(g),"exp-in-out":c(g),"exp-out-in":c(b(g)),"circle-in":h,"circle-out":b(h),"circle-in-out":c(h),"circle-out-in":c(b(h)),"elastic-in":p,"elastic-out":b(p),"elastic-in-out":c(p),"elastic-out-in":c(b(p)),"back-in":q,"back-out":b(q),"back-in-out":c(q),"back-out-in":c(b(q)),"bounce-in":k,"bounce-out":b(k),"bounce-in-out":c(k),"bounce-out-in":c(b(k))};pv.ease=function(n){return m[n]};return{reverse:b,reflect:c,linear:function(){return pv.identity},sin:function(){return f} [...]
+circle:function(){return h},elastic:i,back:j,bounce:k,poly:d}}();
+pv.Transition=function(b){function c(m){for(var n={},r=0;r<m.length;r++){var t=m[r];if(t.id)n[t.id]=t}return n}function d(m,n,r,t){if(n in p)var x=pv.Scale.interpolator(r[n],t[n]),u=function(o){r[n]=x(o)};else u=function(o){if(o>0.5)r[n]=t[n]};u.next=m.head;m.head=u}function f(m,n,r){for(var t in n)t!="children"&&n[t]!=r[t]&&d(m,t,n,r);if(n.children)for(t=0;t<n.children.length;t++)g(m,n.children[t],r.children[t])}function g(m,n,r){for(var t=n.mark,x=c(n),u=c(r),o=0;o<n.length;o++){var v= [...]
+u[v.id]:r[o];v.index=o;if(v.visible){if(!(w&&w.visible)){var y=h(n,o,t.$exit,r);v.transition=w?2:(r.push(y),1);w=y}f(m,v,w)}}for(o=0;o<r.length;o++){w=r[o];v=w.id?x[w.id]:n[o];if(!(v&&v.visible)&&w.visible){y=h(r,o,t.$enter,n);if(v)n[v.index]=y;else n.push(y);f(m,y,w)}}}function h(m,n,r,t){var x=pv.extend(m[n]),u=m.mark,o=u.root.scene,v=(r||q).$properties,w;if(t.target&&(w=t.target[t.length])){m=pv.extend(m);m.target=pv.extend(t.target);m.target[n]=w}var y={};for(r=0;r<v.length;r++)y[v[r [...]
+v=u.binds.optional.filter(function(z){return!(z.name in y)}).concat(v);u.context(m,n,function(){this.buildProperties(x,v);this.buildImplied(x)});u.root.scene=o;return x}function i(m){for(var n=0,r=0;n<m.length;n++){var t=m[n];if(t.transition!=1){m[r++]=t;if(t.transition==2)t.visible=false;t.children&&t.children.forEach(i)}}m.length=r}var j=this,k=pv.ease("cubic-in-out"),l=250,s,p={top:1,left:1,right:1,bottom:1,width:1,height:1,innerRadius:1,outerRadius:1,radius:1,startAngle:1,endAngle:1, [...]
+strokeStyle:1,lineWidth:1,eccentricity:1,tension:1,textAngle:1,textStyle:1,textMargin:1},q=new pv.Transient;j.ease=function(m){return arguments.length?(k=typeof m=="function"?m:pv.ease(m),j):k};j.duration=function(m){return arguments.length?(l=Number(m),j):l};j.start=function(){b.parent&&fail();b.$transition&&b.$transition.stop();b.$transition=j;var m=pv.Mark.prototype.index,n=b.scene,r;b.scene=null;b.bind();b.build();r=b.scene;b.scene=n;pv.Mark.prototype.index=m;var t=Date.now(),x={};g( [...]
+setInterval(function(){for(var u=Math.max(0,Math.min(1,(Date.now()-t)/l)),o=k(u),v=x.head;v;v=v.next)v(o);if(u==1){i(b.scene);j.stop()}pv.Scene.updateAll(n)},24)};j.stop=function(){clearInterval(s)}};pv.Transient=function(b){pv.Mark.call(this);this.fillStyle(null).strokeStyle(null).textStyle(null);this.on=function(c){return b.on(c)}};pv.Transient.prototype=pv.extend(pv.Mark);pv.simulation=function(b){return new pv.Simulation(b)};pv.Simulation=function(b){for(var c=0;c<b.length;c++)this.p [...]
+a=pv.Simulation.prototype;a.particle=function(b){b.next=this.particles;if(isNaN(b.px))b.px=b.x;if(isNaN(b.py))b.py=b.y;if(isNaN(b.fx))b.fx=0;if(isNaN(b.fy))b.fy=0;this.particles=b;return this};a.force=function(b){b.next=this.forces;this.forces=b;return this};a.constraint=function(b){b.next=this.constraints;this.constraints=b;return this};
+a.stabilize=function(b){var c;arguments.length||(b=3);for(var d=0;d<b;d++){var f=new pv.Quadtree(this.particles);for(c=this.constraints;c;c=c.next)c.apply(this.particles,f)}for(c=this.particles;c;c=c.next){c.px=c.x;c.py=c.y}return this};
+a.step=function(){var b;for(b=this.particles;b;b=b.next){var c=b.px,d=b.py;b.px=b.x;b.py=b.y;b.x+=b.vx=b.x-c+b.fx;b.y+=b.vy=b.y-d+b.fy}c=new pv.Quadtree(this.particles);for(b=this.constraints;b;b=b.next)b.apply(this.particles,c);for(b=this.particles;b;b=b.next)b.fx=b.fy=0;for(b=this.forces;b;b=b.next)b.apply(this.particles,c)};
+pv.Quadtree=function(b){function c(l,s,p,q,m,n){if(!(isNaN(s.x)||isNaN(s.y)))if(l.leaf)if(l.p){if(!(Math.abs(l.p.x-s.x)+Math.abs(l.p.y-s.y)<0.01)){var r=l.p;l.p=null;d(l,r,p,q,m,n)}d(l,s,p,q,m,n)}else l.p=s;else d(l,s,p,q,m,n)}function d(l,s,p,q,m,n){var r=(p+m)*0.5,t=(q+n)*0.5,x=s.x>=r,u=s.y>=t;l.leaf=false;switch((u<<1)+x){case 0:l=l.c1||(l.c1=new pv.Quadtree.Node);break;case 1:l=l.c2||(l.c2=new pv.Quadtree.Node);break;case 2:l=l.c3||(l.c3=new pv.Quadtree.Node);break;case 3:l=l.c4||(l. [...]
+break}if(x)p=r;else m=r;if(u)q=t;else n=t;c(l,s,p,q,m,n)}var f,g=Number.POSITIVE_INFINITY,h=g,i=Number.NEGATIVE_INFINITY,j=i;for(f=b;f;f=f.next){if(f.x<g)g=f.x;if(f.y<h)h=f.y;if(f.x>i)i=f.x;if(f.y>j)j=f.y}f=i-g;var k=j-h;if(f>k)j=h+f;else i=g+k;this.xMin=g;this.yMin=h;this.xMax=i;this.yMax=j;this.root=new pv.Quadtree.Node;for(f=b;f;f=f.next)c(this.root,f,g,h,i,j)};pv.Quadtree.Node=function(){this.leaf=true;this.p=this.c4=this.c3=this.c2=this.c1=null};pv.Force={};
+pv.Force.charge=function(b){function c(l){function s(m){c(m);l.cn+=m.cn;p+=m.cn*m.cx;q+=m.cn*m.cy}var p=0,q=0;l.cn=0;if(!l.leaf){l.c1&&s(l.c1);l.c2&&s(l.c2);l.c3&&s(l.c3);l.c4&&s(l.c4)}if(l.p){l.cn+=b;p+=b*l.p.x;q+=b*l.p.y}l.cx=p/l.cn;l.cy=q/l.cn}function d(l,s,p,q,m,n){var r=l.cx-s.x,t=l.cy-s.y,x=1/Math.sqrt(r*r+t*t);if(l.leaf&&l.p!=s||(m-p)*x<j){if(!(x<i)){if(x>g)x=g;l=l.cn*x*x*x;r=r*l;t=t*l;s.fx+=r;s.fy+=t}}else if(!l.leaf){var u=(p+m)*0.5,o=(q+n)*0.5;l.c1&&d(l.c1,s,p,q,u,o);l.c2&&d(l [...]
+m,o);l.c3&&d(l.c3,s,p,o,u,n);l.c4&&d(l.c4,s,u,o,m,n);if(!(x<i)){if(x>g)x=g;if(l.p&&l.p!=s){l=b*x*x*x;r=r*l;t=t*l;s.fx+=r;s.fy+=t}}}}var f=2,g=1/f,h=500,i=1/h,j=0.9,k={};arguments.length||(b=-40);k.constant=function(l){if(arguments.length){b=Number(l);return k}return b};k.domain=function(l,s){if(arguments.length){f=Number(l);g=1/f;h=Number(s);i=1/h;return k}return[f,h]};k.theta=function(l){if(arguments.length){j=Number(l);return k}return j};k.apply=function(l,s){c(s.root);for(l=l;l;l=l.ne [...]
+l,s.xMin,s.yMin,s.xMax,s.yMax)};return k};pv.Force.drag=function(b){var c={};arguments.length||(b=0.1);c.constant=function(d){if(arguments.length){b=d;return c}return b};c.apply=function(d){if(b)for(d=d;d;d=d.next){d.fx-=b*d.vx;d.fy-=b*d.vy}};return c};
+pv.Force.spring=function(b){var c=0.1,d=20,f,g,h={};arguments.length||(b=0.1);h.links=function(i){if(arguments.length){f=i;g=i.map(function(j){return 1/Math.sqrt(Math.max(j.sourceNode.linkDegree,j.targetNode.linkDegree))});return h}return f};h.constant=function(i){if(arguments.length){b=Number(i);return h}return b};h.damping=function(i){if(arguments.length){c=Number(i);return h}return c};h.length=function(i){if(arguments.length){d=Number(i);return h}return d};h.apply=function(){for(var i [...]
+f[i].sourceNode,k=f[i].targetNode,l=j.x-k.x,s=j.y-k.y,p=Math.sqrt(l*l+s*s),q=p?1/p:1;q=(b*g[i]*(p-d)+c*g[i]*(l*(j.vx-k.vx)+s*(j.vy-k.vy))*q)*q;l=-q*(p?l:0.01*(0.5-Math.random()));s=-q*(p?s:0.01*(0.5-Math.random()));j.fx+=l;j.fy+=s;k.fx-=l;k.fy-=s}};return h};pv.Constraint={};
+pv.Constraint.collision=function(b){function c(l,s,p,q,m,n){if(!l.leaf){var r=(p+m)*0.5,t=(q+n)*0.5,x=t<j,u=r>g,o=r<i;if(t>h){l.c1&&u&&c(l.c1,s,p,q,r,t);l.c2&&o&&c(l.c2,s,r,q,m,t)}if(x){l.c3&&u&&c(l.c3,s,p,t,r,n);l.c4&&o&&c(l.c4,s,r,t,m,n)}}if(l.p&&l.p!=s){p=s.x-l.p.x;q=s.y-l.p.y;m=Math.sqrt(p*p+q*q);n=f+b(l.p);if(m<n){m=(m-n)/m*0.5;p*=m;q*=m;s.x-=p;s.y-=q;l.p.x+=p;l.p.y+=q}}}var d=1,f,g,h,i,j,k={};arguments.length||(f=10);k.repeat=function(l){if(arguments.length){d=Number(l);return k}re [...]
+function(l,s){var p,q,m=-Infinity;for(p=l;p;p=p.next){q=b(p);if(q>m)m=q}for(var n=0;n<d;n++)for(p=l;p;p=p.next){q=(f=b(p))+m;g=p.x-q;i=p.x+q;h=p.y-q;j=p.y+q;c(s.root,p,s.xMin,s.yMin,s.xMax,s.yMax)}};return k};pv.Constraint.position=function(b){var c=1,d={};arguments.length||(b=function(f){return f.fix});d.alpha=function(f){if(arguments.length){c=Number(f);return d}return c};d.apply=function(f){for(f=f;f;f=f.next){var g=b(f);if(g){f.x+=(g.x-f.x)*c;f.y+=(g.y-f.y)*c;f.fx=f.fy=f.vx=f.vy=0}}} [...]
+pv.Constraint.bound=function(){var b={},c,d;b.x=function(f,g){if(arguments.length){c={min:Math.min(f,g),max:Math.max(f,g)};return this}return c};b.y=function(f,g){if(arguments.length){d={min:Math.min(f,g),max:Math.max(f,g)};return this}return d};b.apply=function(f){if(c)for(var g=f;g;g=g.next)g.x=g.x<c.min?c.min:g.x>c.max?c.max:g.x;if(d)for(g=f;g;g=g.next)g.y=g.y<d.min?d.min:g.y>d.max?d.max:g.y};return b};pv.Layout=function(){pv.Panel.call(this)};pv.Layout.prototype=pv.extend(pv.Panel);
+pv.Layout.prototype.property=function(b,c){if(!this.hasOwnProperty("properties"))this.properties=pv.extend(this.properties);this.properties[b]=true;this.propertyMethod(b,false,pv.Mark.cast[b]=c);return this};
+pv.Layout.Network=function(){pv.Layout.call(this);var b=this;this.$id=pv.id();(this.node=(new pv.Mark).data(function(){return b.nodes()}).strokeStyle("#1f77b4").fillStyle("#fff").left(function(c){return c.x}).top(function(c){return c.y})).parent=this;this.link=(new pv.Mark).extend(this.node).data(function(c){return[c.sourceNode,c.targetNode]}).fillStyle(null).lineWidth(function(c,d){return d.linkValue*1.5}).strokeStyle("rgba(0,0,0,.2)");this.link.add=function(c){return b.add(pv.Panel).da [...]
+(this.label=(new pv.Mark).extend(this.node).textMargin(7).textBaseline("middle").text(function(c){return c.nodeName||c.nodeValue}).textAngle(function(c){c=c.midAngle;return pv.Wedge.upright(c)?c:c+Math.PI}).textAlign(function(c){return pv.Wedge.upright(c.midAngle)?"left":"right"})).parent=this};
+pv.Layout.Network.prototype=pv.extend(pv.Layout).property("nodes",function(b){return b.map(function(c,d){if(typeof c!="object")c={nodeValue:c};c.index=d;return c})}).property("links",function(b){return b.map(function(c){if(isNaN(c.linkValue))c.linkValue=isNaN(c.value)?1:c.value;return c})});pv.Layout.Network.prototype.reset=function(){this.$id=pv.id();return this};pv.Layout.Network.prototype.buildProperties=function(b,c){if((b.$id||0)<this.$id)pv.Layout.prototype.buildProperties.call(thi [...]
+pv.Layout.Network.prototype.buildImplied=function(b){pv.Layout.prototype.buildImplied.call(this,b);if(b.$id>=this.$id)return true;b.$id=this.$id;b.nodes.forEach(function(c){c.linkDegree=0});b.links.forEach(function(c){var d=c.linkValue;(c.sourceNode||(c.sourceNode=b.nodes[c.source])).linkDegree+=d;(c.targetNode||(c.targetNode=b.nodes[c.target])).linkDegree+=d})};pv.Layout.Hierarchy=function(){pv.Layout.Network.call(this);this.link.strokeStyle("#ccc")};pv.Layout.Hierarchy.prototype=pv.ext [...]
+pv.Layout.Hierarchy.prototype.buildImplied=function(b){if(!b.links)b.links=pv.Layout.Hierarchy.links.call(this);pv.Layout.Network.prototype.buildImplied.call(this,b)};pv.Layout.Hierarchy.links=function(){return this.nodes().filter(function(b){return b.parentNode}).map(function(b){return{sourceNode:b,targetNode:b.parentNode,linkValue:1}})};
+pv.Layout.Hierarchy.NodeLink={buildImplied:function(b){function c(m){return m.parentNode?m.depth*(p-s)+s:0}function d(m){return m.parentNode?(m.breadth-0.25)*2*Math.PI:0}function f(m){switch(i){case "left":return m.depth*k;case "right":return k-m.depth*k;case "top":return m.breadth*k;case "bottom":return k-m.breadth*k;case "radial":return k/2+c(m)*Math.cos(m.midAngle)}}function g(m){switch(i){case "left":return m.breadth*l;case "right":return l-m.breadth*l;case "top":return m.depth*l;cas [...]
+m.depth*l;case "radial":return l/2+c(m)*Math.sin(m.midAngle)}}var h=b.nodes,i=b.orient,j=/^(top|bottom)$/.test(i),k=b.width,l=b.height;if(i=="radial"){var s=b.innerRadius,p=b.outerRadius;if(s==null)s=0;if(p==null)p=Math.min(k,l)/2}for(b=0;b<h.length;b++){var q=h[b];q.midAngle=i=="radial"?d(q):j?Math.PI/2:0;q.x=f(q);q.y=g(q);if(q.firstChild)q.midAngle+=Math.PI}}};
+pv.Layout.Hierarchy.Fill={constructor:function(){this.node.strokeStyle("#fff").fillStyle("#ccc").width(function(b){return b.dx}).height(function(b){return b.dy}).innerRadius(function(b){return b.innerRadius}).outerRadius(function(b){return b.outerRadius}).startAngle(function(b){return b.startAngle}).angle(function(b){return b.angle});this.label.textAlign("center").left(function(b){return b.x+b.dx/2}).top(function(b){return b.y+b.dy/2});delete this.link},buildImplied:function(b){function  [...]
+v)/(1+v)}function d(o){switch(p){case "left":return c(o.minDepth,r)*m;case "right":return(1-c(o.maxDepth,r))*m;case "top":return o.minBreadth*m;case "bottom":return(1-o.maxBreadth)*m;case "radial":return m/2}}function f(o){switch(p){case "left":return o.minBreadth*n;case "right":return(1-o.maxBreadth)*n;case "top":return c(o.minDepth,r)*n;case "bottom":return(1-c(o.maxDepth,r))*n;case "radial":return n/2}}function g(o){switch(p){case "left":case "right":return(o.maxDepth-o.minDepth)/(1+r [...]
+o.minBreadth)*m;case "radial":return o.parentNode?(o.innerRadius+o.outerRadius)*Math.cos(o.midAngle):0}}function h(o){switch(p){case "left":case "right":return(o.maxBreadth-o.minBreadth)*n;case "top":case "bottom":return(o.maxDepth-o.minDepth)/(1+r)*n;case "radial":return o.parentNode?(o.innerRadius+o.outerRadius)*Math.sin(o.midAngle):0}}function i(o){return Math.max(0,c(o.minDepth,r/2))*(x-t)+t}function j(o){return c(o.maxDepth,r/2)*(x-t)+t}function k(o){return(o.parentNode?o.minBreadth [...]
+2*Math.PI}function l(o){return(o.parentNode?o.maxBreadth-o.minBreadth:1)*2*Math.PI}var s=b.nodes,p=b.orient,q=/^(top|bottom)$/.test(p),m=b.width,n=b.height,r=-s[0].minDepth;if(p=="radial"){var t=b.innerRadius,x=b.outerRadius;if(t==null)t=0;if(t)r*=2;if(x==null)x=Math.min(m,n)/2}for(b=0;b<s.length;b++){var u=s[b];u.x=d(u);u.y=f(u);if(p=="radial"){u.innerRadius=i(u);u.outerRadius=j(u);u.startAngle=k(u);u.angle=l(u);u.midAngle=u.startAngle+u.angle/2}else u.midAngle=q?-Math.PI/2:0;u.dx=g(u); [...]
+pv.Layout.Grid=function(){pv.Layout.call(this);var b=this;(this.cell=(new pv.Mark).data(function(){return b.scene[b.index].$grid}).width(function(){return b.width()/b.cols()}).height(function(){return b.height()/b.rows()}).left(function(){return this.width()*(this.index%b.cols())}).top(function(){return this.height()*Math.floor(this.index/b.cols())})).parent=this};pv.Layout.Grid.prototype=pv.extend(pv.Layout).property("rows").property("cols");pv.Layout.Grid.prototype.defaults=(new pv.Lay [...]
+pv.Layout.Grid.prototype.buildImplied=function(b){pv.Layout.prototype.buildImplied.call(this,b);var c=b.rows,d=b.cols;if(typeof d=="object")c=pv.transpose(d);if(typeof c=="object"){b.$grid=pv.blend(c);b.rows=c.length;b.cols=c[0]?c[0].length:0}else b.$grid=pv.repeat([b.data],c*d)};
+pv.Layout.Stack=function(){function b(i){return function(){return f[i](this.parent.index,this.index)}}pv.Layout.call(this);var c=this,d=function(){return null},f={t:d,l:d,r:d,b:d,w:d,h:d},g,h=c.buildImplied;this.buildImplied=function(i){h.call(this,i);var j=i.layers,k=j.length,l,s=i.orient,p=/^(top|bottom)\b/.test(s),q=this.parent[p?"height":"width"](),m=[],n=[],r=[],t=pv.Mark.stack,x={parent:{parent:this}};t.unshift(null);g=[];for(var u=0;u<k;u++){r[u]=[];n[u]=[];x.parent.index=u;t[0]=j [...]
+this.$values.apply(x.parent,t);if(!u)l=g[u].length;t.unshift(null);for(var o=0;o<l;o++){t[0]=g[u][o];x.index=o;u||(m[o]=this.$x.apply(x,t));r[u][o]=this.$y.apply(x,t)}t.shift()}t.shift();switch(i.order){case "inside-out":var v=r.map(function(A){return pv.max.index(A)});x=pv.range(k).sort(function(A,D){return v[A]-v[D]});j=r.map(function(A){return pv.sum(A)});var w=t=0,y=[],z=[];for(u=0;u<k;u++){o=x[u];if(t<w){t+=j[o];y.push(o)}else{w+=j[o];z.push(o)}}j=z.reverse().concat(y);break;case "r [...]
+pv.range(k-1,-1,-1);break;default:j=pv.range(k);break}switch(i.offset){case "silohouette":for(o=0;o<l;o++){for(u=x=0;u<k;u++)x+=r[u][o];n[j[0]][o]=(q-x)/2}break;case "wiggle":for(u=x=0;u<k;u++)x+=r[u][0];n[j[0]][0]=x=(q-x)/2;for(o=1;o<l;o++){t=q=0;w=m[o]-m[o-1];for(u=0;u<k;u++)q+=r[u][o];for(u=0;u<k;u++){y=(r[j[u]][o]-r[j[u]][o-1])/(2*w);for(i=0;i<u;i++)y+=(r[j[i]][o]-r[j[i]][o-1])/w;t+=y*r[j[u]][o]}n[j[0]][o]=x-=q?t/q*w:0}break;case "expand":for(o=0;o<l;o++){for(u=i=n[j[0]][o]=0;u<k;u++ [...]
+if(i){i=q/i;for(u=0;u<k;u++)r[u][o]*=i}else{i=q/k;for(u=0;u<k;u++)r[u][o]=i}}break;default:for(o=0;o<l;o++)n[j[0]][o]=0;break}for(o=0;o<l;o++){x=n[j[0]][o];for(u=1;u<k;u++){x+=r[j[u-1]][o];n[j[u]][o]=x}}u=s.indexOf("-");k=p?"h":"w";p=u<0?p?"l":"b":s.charAt(u+1);s=s.charAt(0);for(var C in f)f[C]=d;f[p]=function(A,D){return m[D]};f[s]=function(A,D){return n[A][D]};f[k]=function(A,D){return r[A][D]}};this.layer=(new pv.Mark).data(function(){return g[this.parent.index]}).top(b("t")).left(b(" [...]
+this.layer.add=function(i){return c.add(pv.Panel).data(function(){return c.layers()}).add(i).extend(this)}};pv.Layout.Stack.prototype=pv.extend(pv.Layout).property("orient",String).property("offset",String).property("order",String).property("layers");a=pv.Layout.Stack.prototype;a.defaults=(new pv.Layout.Stack).extend(pv.Layout.prototype.defaults).orient("bottom-left").offset("zero").layers([[]]);a.$x=pv.Layout.Stack.prototype.$y=function(){return 0};a.x=function(b){this.$x=pv.functor(b); [...]
+a.y=function(b){this.$y=pv.functor(b);return this};a.$values=pv.identity;a.values=function(b){this.$values=pv.functor(b);return this};
+pv.Layout.Treemap=function(){pv.Layout.Hierarchy.call(this);this.node.strokeStyle("#fff").fillStyle("rgba(31, 119, 180, .25)").width(function(b){return b.dx}).height(function(b){return b.dy});this.label.visible(function(b){return!b.firstChild}).left(function(b){return b.x+b.dx/2}).top(function(b){return b.y+b.dy/2}).textAlign("center").textAngle(function(b){return b.dx>b.dy?0:-Math.PI/2});(this.leaf=(new pv.Mark).extend(this.node).fillStyle(null).strokeStyle(null).visible(function(b){ret [...]
+this;delete this.link};pv.Layout.Treemap.prototype=pv.extend(pv.Layout.Hierarchy).property("round",Boolean).property("paddingLeft",Number).property("paddingRight",Number).property("paddingTop",Number).property("paddingBottom",Number).property("mode",String).property("order",String);a=pv.Layout.Treemap.prototype;a.defaults=(new pv.Layout.Treemap).extend(pv.Layout.Hierarchy.prototype.defaults).mode("squarify").order("ascending");a.padding=function(b){return this.paddingLeft(b).paddingRight [...]
+a.$size=function(b){return Number(b.nodeValue)};a.size=function(b){this.$size=pv.functor(b);return this};
+a.buildImplied=function(b){function c(n,r,t,x,u,o,v){for(var w=0,y=0;w<n.length;w++){var z=n[w];if(t){z.x=x+y;z.y=u;y+=z.dx=q(o*z.size/r);z.dy=v}else{z.x=x;z.y=u+y;z.dx=o;y+=z.dy=q(v*z.size/r)}}if(z)if(t)z.dx+=o-y;else z.dy+=v-y}function d(n,r){for(var t=-Infinity,x=Infinity,u=0,o=0;o<n.length;o++){var v=n[o].size;if(v<x)x=v;if(v>t)t=v;u+=v}u*=u;r*=r;return Math.max(r*t/u,u/(r*x))}function f(n,r){function t(A){var D=o==y,G=pv.sum(A,p),E=y?q(G/y):0;c(A,G,D,x,u,D?o:E,D?E:v);if(D){u+=E;v-=E [...]
+E;o-=E}y=Math.min(o,v);return D}var x=n.x+j,u=n.y+l,o=n.dx-j-k,v=n.dy-l-s;if(m!="squarify")c(n.childNodes,n.size,m=="slice"?true:m=="dice"?false:r&1,x,u,o,v);else{var w=[];r=Infinity;var y=Math.min(o,v),z=o*v/n.size;if(!(n.size<=0)){n.visitBefore(function(A){A.size*=z});for(n=n.childNodes.slice();n.length;){var C=n[n.length-1];if(C.size){w.push(C);z=d(w,y);if(z<=r){n.pop();r=z}else{w.pop();t(w);w.length=0;r=Infinity}}else n.pop()}if(t(w))for(r=0;r<w.length;r++)w[r].dy+=v;else for(r=0;r<w [...]
+o}}}if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var g=this,h=b.nodes[0],i=pv.Mark.stack,j=b.paddingLeft,k=b.paddingRight,l=b.paddingTop,s=b.paddingBottom,p=function(n){return n.size},q=b.round?Math.round:Number,m=b.mode;i.unshift(null);h.visitAfter(function(n,r){n.depth=r;n.x=n.y=n.dx=n.dy=0;n.size=n.firstChild?pv.sum(n.childNodes,function(t){return t.size}):g.$size.apply(g,(i[0]=n,i))});i.shift();switch(b.order){case "ascending":h.sort(function(n,r){return n.size-r.size [...]
+case "descending":h.sort(function(n,r){return r.size-n.size});break;case "reverse":h.reverse();break}h.x=0;h.y=0;h.dx=b.width;h.dy=b.height;h.visitBefore(f)}};pv.Layout.Tree=function(){pv.Layout.Hierarchy.call(this)};pv.Layout.Tree.prototype=pv.extend(pv.Layout.Hierarchy).property("group",Number).property("breadth",Number).property("depth",Number).property("orient",String);pv.Layout.Tree.prototype.defaults=(new pv.Layout.Tree).extend(pv.Layout.Hierarchy.prototype.defaults).group(1).bread [...]
+pv.Layout.Tree.prototype.buildImplied=function(b){function c(o){var v,w,y;if(o.firstChild){v=o.firstChild;w=o.lastChild;for(var z=y=v;z;z=z.nextSibling){c(z);y=f(z,y)}j(o);w=0.5*(v.prelim+w.prelim);if(v=o.previousSibling){o.prelim=v.prelim+l(o.depth,true);o.mod=o.prelim-w}else o.prelim=w}else if(v=o.previousSibling)o.prelim=v.prelim+l(o.depth,true)}function d(o,v,w){o.breadth=o.prelim+v;v+=o.mod;for(o=o.firstChild;o;o=o.nextSibling)d(o,v,w)}function f(o,v){var w=o.previousSibling;if(w){v [...]
+o,C=w;w=o.parentNode.firstChild;var A=y.mod,D=z.mod,G=C.mod,E=w.mod;C=h(C);for(y=g(y);C&&y;){C=C;y=y;w=g(w);z=h(z);z.ancestor=o;var B=C.prelim+G-(y.prelim+A)+l(C.depth,false);if(B>0){i(k(C,o,v),o,B);A+=B;D+=B}G+=C.mod;A+=y.mod;E+=w.mod;D+=z.mod;C=h(C);y=g(y)}if(C&&!h(z)){z.thread=C;z.mod+=G-D}if(y&&!g(w)){w.thread=y;w.mod+=A-E;v=o}}return v}function g(o){return o.firstChild||o.thread}function h(o){return o.lastChild||o.thread}function i(o,v,w){var y=v.number-o.number;v.change-=w/y;v.shif [...]
+w/y;v.prelim+=w;v.mod+=w}function j(o){var v=0,w=0;for(o=o.lastChild;o;o=o.previousSibling){o.prelim+=v;o.mod+=v;w+=o.change;v+=o.shift+w}}function k(o,v,w){return o.ancestor.parentNode==v.parentNode?o.ancestor:w}function l(o,v){return(v?1:t+1)/(m=="radial"?o:1)}function s(o){return m=="radial"?o.breadth/n:0}function p(o){switch(m){case "left":return o.depth;case "right":return x-o.depth;case "top":case "bottom":return o.breadth+x/2;case "radial":return x/2+o.depth*Math.cos(s(o))}}functi [...]
+u/2;case "top":return o.depth;case "bottom":return u-o.depth;case "radial":return u/2+o.depth*Math.sin(s(o))}}if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var m=b.orient,n=b.depth,r=b.breadth,t=b.group,x=b.width,u=b.height;b=b.nodes[0];b.visitAfter(function(o,v){o.ancestor=o;o.prelim=0;o.mod=0;o.change=0;o.shift=0;o.number=o.previousSibling?o.previousSibling.number+1:0;o.depth=v});c(b);d(b,-b.prelim,0);b.visitAfter(function(o){o.breadth*=r;o.depth*=n;o.midAngle=s(o);o.x=p [...]
+if(o.firstChild)o.midAngle+=Math.PI;delete o.breadth;delete o.depth;delete o.ancestor;delete o.prelim;delete o.mod;delete o.change;delete o.shift;delete o.number;delete o.thread})}};pv.Layout.Indent=function(){pv.Layout.Hierarchy.call(this);this.link.interpolate("step-after")};pv.Layout.Indent.prototype=pv.extend(pv.Layout.Hierarchy).property("depth",Number).property("breadth",Number);pv.Layout.Indent.prototype.defaults=(new pv.Layout.Indent).extend(pv.Layout.Hierarchy.prototype.defaults [...]
+pv.Layout.Indent.prototype.buildImplied=function(b){function c(i,j,k){i.x=g+k++*f;i.y=h+j++*d;i.midAngle=0;for(i=i.firstChild;i;i=i.nextSibling)j=c(i,j,k);return j}if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var d=b.breadth,f=b.depth,g=0,h=0;c(b.nodes[0],1,1)}};pv.Layout.Pack=function(){pv.Layout.Hierarchy.call(this);this.node.shapeRadius(function(b){return b.radius}).strokeStyle("rgb(31, 119, 180)").fillStyle("rgba(31, 119, 180, .25)");this.label.textAlign("center");del [...]
+pv.Layout.Pack.prototype=pv.extend(pv.Layout.Hierarchy).property("spacing",Number).property("order",String);pv.Layout.Pack.prototype.defaults=(new pv.Layout.Pack).extend(pv.Layout.Hierarchy.prototype.defaults).spacing(1).order("ascending");pv.Layout.Pack.prototype.$radius=function(){return 1};pv.Layout.Pack.prototype.size=function(b){this.$radius=typeof b=="function"?function(){return Math.sqrt(b.apply(this,arguments))}:(b=Math.sqrt(b),function(){return b});return this};
+pv.Layout.Pack.prototype.buildImplied=function(b){function c(p){var q=pv.Mark.stack;q.unshift(null);for(var m=0,n=p.length;m<n;m++){var r=p[m];if(!r.firstChild)r.radius=i.$radius.apply(i,(q[0]=r,q))}q.shift()}function d(p){var q=[];for(p=p.firstChild;p;p=p.nextSibling){if(p.firstChild)p.radius=d(p);p.n=p.p=p;q.push(p)}switch(b.order){case "ascending":q.sort(function(m,n){return m.radius-n.radius});break;case "descending":q.sort(function(m,n){return n.radius-m.radius});break;case "reverse [...]
+break}return f(q)}function f(p){function q(B){t=Math.min(B.x-B.radius,t);x=Math.max(B.x+B.radius,x);u=Math.min(B.y-B.radius,u);o=Math.max(B.y+B.radius,o)}function m(B,F){var H=B.n;B.n=F;F.p=B;F.n=H;H.p=F}function n(B,F){B.n=F;F.p=B}function r(B,F){var H=F.x-B.x,I=F.y-B.y;B=B.radius+F.radius;return B*B-H*H-I*I>0.0010}var t=Infinity,x=-Infinity,u=Infinity,o=-Infinity,v,w,y,z,C;v=p[0];v.x=-v.radius;v.y=0;q(v);if(p.length>1){w=p[1];w.x=w.radius;w.y=0;q(w);if(p.length>2){y=p[2];g(v,w,y);q(y); [...]
+y;m(y,w);w=v.n;for(var A=3;A<p.length;A++){g(v,w,y=p[A]);var D=0,G=1,E=1;for(z=w.n;z!=w;z=z.n,G++)if(r(z,y)){D=1;break}if(D==1)for(C=v.p;C!=z.p;C=C.p,E++)if(r(C,y)){if(E<G){D=-1;z=C}break}if(D==0){m(v,y);w=y;q(y)}else if(D>0){n(v,z);w=z;A--}else if(D<0){n(z,w);v=z;A--}}}}v=(t+x)/2;w=(u+o)/2;for(A=y=0;A<p.length;A++){z=p[A];z.x-=v;z.y-=w;y=Math.max(y,z.radius+Math.sqrt(z.x*z.x+z.y*z.y))}return y+b.spacing}function g(p,q,m){var n=q.radius+m.radius,r=p.radius+m.radius,t=q.x-p.x;q=q.y-p.y;va [...]
+t+q*q),u=(r*r+x*x-n*n)/(2*r*x);n=Math.acos(u);u=u*r;r=Math.sin(n)*r;t/=x;q/=x;m.x=p.x+u*t+r*q;m.y=p.y+u*q-r*t}function h(p,q,m,n){for(var r=p.firstChild;r;r=r.nextSibling){r.x+=p.x;r.y+=p.y;h(r,q,m,n)}p.x=q+n*p.x;p.y=m+n*p.y;p.radius*=n}if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var i=this,j=b.nodes,k=j[0];c(j);k.x=0;k.y=0;k.radius=d(k);j=this.width();var l=this.height(),s=1/Math.max(2*k.radius/j,2*k.radius/l);h(k,j/2,l/2,s)}};
+pv.Layout.Force=function(){pv.Layout.Network.call(this);this.link.lineWidth(function(b,c){return Math.sqrt(c.linkValue)*1.5});this.label.textAlign("center")};
+pv.Layout.Force.prototype=pv.extend(pv.Layout.Network).property("bound",Boolean).property("iterations",Number).property("dragConstant",Number).property("chargeConstant",Number).property("chargeMinDistance",Number).property("chargeMaxDistance",Number).property("chargeTheta",Number).property("springConstant",Number).property("springDamping",Number).property("springLength",Number);pv.Layout.Force.prototype.defaults=(new pv.Layout.Force).extend(pv.Layout.Network.prototype.defaults).dragConst [...]
+pv.Layout.Force.prototype.buildImplied=function(b){function c(s){return s.fix?1:s.vx*s.vx+s.vy*s.vy}if(pv.Layout.Network.prototype.buildImplied.call(this,b)){if(b=b.$force){b.next=this.binds.$force;this.binds.$force=b}}else{for(var d=this,f=b.nodes,g=b.links,h=b.iterations,i=b.width,j=b.height,k=0,l;k<f.length;k++){l=f[k];if(isNaN(l.x))l.x=i/2+40*Math.random()-20;if(isNaN(l.y))l.y=j/2+40*Math.random()-20}l=pv.simulation(f);l.force(pv.Force.drag(b.dragConstant));l.force(pv.Force.charge(b. [...]
+b.chargeMaxDistance).theta(b.chargeTheta));l.force(pv.Force.spring(b.springConstant).damping(b.springDamping).length(b.springLength).links(g));l.constraint(pv.Constraint.position());b.bound&&l.constraint(pv.Constraint.bound().x(6,i-6).y(6,j-6));if(h==null){l.step();l.step();b.$force=this.binds.$force={next:this.binds.$force,nodes:f,min:1.0E-4*(g.length+1),sim:l};if(!this.$timer)this.$timer=setInterval(function(){for(var s=false,p=d.binds.$force;p;p=p.next)if(pv.max(p.nodes,c)>p.min){p.si [...]
+s=true}s&&d.render()},42)}else for(k=0;k<h;k++)l.step()}};pv.Layout.Cluster=function(){pv.Layout.Hierarchy.call(this);var b,c=this.buildImplied;this.buildImplied=function(d){c.call(this,d);b=/^(top|bottom)$/.test(d.orient)?"step-before":/^(left|right)$/.test(d.orient)?"step-after":"linear"};this.link.interpolate(function(){return b})};
+pv.Layout.Cluster.prototype=pv.extend(pv.Layout.Hierarchy).property("group",Number).property("orient",String).property("innerRadius",Number).property("outerRadius",Number);pv.Layout.Cluster.prototype.defaults=(new pv.Layout.Cluster).extend(pv.Layout.Hierarchy.prototype.defaults).group(0).orient("top");
+pv.Layout.Cluster.prototype.buildImplied=function(b){if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var c=b.nodes[0],d=b.group,f,g,h=0,i=0.5-d/2,j=undefined;c.visitAfter(function(k){if(k.firstChild)k.depth=1+pv.max(k.childNodes,function(l){return l.depth});else{if(d&&j!=k.parentNode){j=k.parentNode;h+=d}h++;k.depth=0}});f=1/h;g=1/c.depth;j=undefined;c.visitAfter(function(k){if(k.firstChild)k.breadth=pv.mean(k.childNodes,function(l){return l.breadth});else{if(d&&j!=k.parentN [...]
+i+=d}k.breadth=f*i++}k.depth=1-k.depth*g});c.visitAfter(function(k){k.minBreadth=k.firstChild?k.firstChild.minBreadth:k.breadth-f/2;k.maxBreadth=k.firstChild?k.lastChild.maxBreadth:k.breadth+f/2});c.visitBefore(function(k){k.minDepth=k.parentNode?k.parentNode.maxDepth:0;k.maxDepth=k.parentNode?k.depth+c.depth:k.minDepth+2*c.depth});c.minDepth=-g;pv.Layout.Hierarchy.NodeLink.buildImplied.call(this,b)}};pv.Layout.Cluster.Fill=function(){pv.Layout.Cluster.call(this);pv.Layout.Hierarchy.Fill [...]
+pv.Layout.Cluster.Fill.prototype=pv.extend(pv.Layout.Cluster);pv.Layout.Cluster.Fill.prototype.buildImplied=function(b){pv.Layout.Cluster.prototype.buildImplied.call(this,b)||pv.Layout.Hierarchy.Fill.buildImplied.call(this,b)};pv.Layout.Partition=function(){pv.Layout.Hierarchy.call(this)};pv.Layout.Partition.prototype=pv.extend(pv.Layout.Hierarchy).property("order",String).property("orient",String).property("innerRadius",Number).property("outerRadius",Number);
+pv.Layout.Partition.prototype.defaults=(new pv.Layout.Partition).extend(pv.Layout.Hierarchy.prototype.defaults).orient("top");pv.Layout.Partition.prototype.$size=function(){return 1};pv.Layout.Partition.prototype.size=function(b){this.$size=b;return this};
+pv.Layout.Partition.prototype.buildImplied=function(b){if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var c=this,d=b.nodes[0],f=pv.Mark.stack,g=0;f.unshift(null);d.visitAfter(function(i,j){if(j>g)g=j;i.size=i.firstChild?pv.sum(i.childNodes,function(k){return k.size}):c.$size.apply(c,(f[0]=i,f))});f.shift();switch(b.order){case "ascending":d.sort(function(i,j){return i.size-j.size});break;case "descending":d.sort(function(i,j){return j.size-i.size});break}var h=1/g;d.minBrea [...]
+0.5;d.maxBreadth=1;d.visitBefore(function(i){for(var j=i.minBreadth,k=i.maxBreadth-j,l=i.firstChild;l;l=l.nextSibling){l.minBreadth=j;l.maxBreadth=j+=l.size/i.size*k;l.breadth=(j+l.minBreadth)/2}});d.visitAfter(function(i,j){i.minDepth=(j-1)*h;i.maxDepth=i.depth=j*h});pv.Layout.Hierarchy.NodeLink.buildImplied.call(this,b)}};pv.Layout.Partition.Fill=function(){pv.Layout.Partition.call(this);pv.Layout.Hierarchy.Fill.constructor.call(this)};pv.Layout.Partition.Fill.prototype=pv.extend(pv.La [...]
+pv.Layout.Partition.Fill.prototype.buildImplied=function(b){pv.Layout.Partition.prototype.buildImplied.call(this,b)||pv.Layout.Hierarchy.Fill.buildImplied.call(this,b)};pv.Layout.Arc=function(){pv.Layout.Network.call(this);var b,c,d,f=this.buildImplied;this.buildImplied=function(g){f.call(this,g);c=g.directed;b=g.orient=="radial"?"linear":"polar";d=g.orient=="right"||g.orient=="top"};this.link.data(function(g){var h=g.sourceNode;g=g.targetNode;return d!=(c||h.breadth<g.breadth)?[h,g]:[g, [...]
+pv.Layout.Arc.prototype=pv.extend(pv.Layout.Network).property("orient",String).property("directed",Boolean);pv.Layout.Arc.prototype.defaults=(new pv.Layout.Arc).extend(pv.Layout.Network.prototype.defaults).orient("bottom");pv.Layout.Arc.prototype.sort=function(b){this.$sort=b;return this};
+pv.Layout.Arc.prototype.buildImplied=function(b){function c(m){switch(h){case "top":return-Math.PI/2;case "bottom":return Math.PI/2;case "left":return Math.PI;case "right":return 0;case "radial":return(m-0.25)*2*Math.PI}}function d(m){switch(h){case "top":case "bottom":return m*k;case "left":return 0;case "right":return k;case "radial":return k/2+s*Math.cos(c(m))}}function f(m){switch(h){case "top":return 0;case "bottom":return l;case "left":case "right":return m*l;case "radial":return l [...]
+if(!pv.Layout.Network.prototype.buildImplied.call(this,b)){var g=b.nodes,h=b.orient,i=this.$sort,j=pv.range(g.length),k=b.width,l=b.height,s=Math.min(k,l)/2;i&&j.sort(function(m,n){return i(g[m],g[n])});for(b=0;b<g.length;b++){var p=g[j[b]],q=p.breadth=(b+0.5)/g.length;p.x=d(q);p.y=f(q);p.midAngle=c(q)}}};
+pv.Layout.Horizon=function(){pv.Layout.call(this);var b=this,c,d,f,g,h,i,j=this.buildImplied;this.buildImplied=function(k){j.call(this,k);c=k.bands;d=k.mode;f=Math.round((d=="color"?0.5:1)*k.height);g=k.backgroundStyle;h=pv.ramp(g,k.negativeStyle).domain(0,c);i=pv.ramp(g,k.positiveStyle).domain(0,c)};c=(new pv.Panel).data(function(){return pv.range(c*2)}).overflow("hidden").height(function(){return f}).top(function(k){return d=="color"?(k&1)*f:0}).fillStyle(function(k){return k?null:g}); [...]
+(new pv.Mark).top(function(k,l){return d=="mirror"&&l&1?(l+1>>1)*f:null}).bottom(function(k,l){return d=="mirror"?l&1?null:(l+1>>1)*-f:(l&1||-1)*(l+1>>1)*f}).fillStyle(function(k,l){return(l&1?h:i)((l>>1)+1)});this.band.add=function(k){return b.add(pv.Panel).extend(c).add(k).extend(this)}};pv.Layout.Horizon.prototype=pv.extend(pv.Layout).property("bands",Number).property("mode",String).property("backgroundStyle",pv.color).property("positiveStyle",pv.color).property("negativeStyle",pv.color);
+pv.Layout.Horizon.prototype.defaults=(new pv.Layout.Horizon).extend(pv.Layout.prototype.defaults).bands(2).mode("offset").backgroundStyle("white").positiveStyle("#1f77b4").negativeStyle("#d62728");
+pv.Layout.Rollup=function(){pv.Layout.Network.call(this);var b=this,c,d,f=b.buildImplied;this.buildImplied=function(g){f.call(this,g);c=g.$rollup.nodes;d=g.$rollup.links};this.node.data(function(){return c}).shapeSize(function(g){return g.nodes.length*20});this.link.interpolate("polar").eccentricity(0.8);this.link.add=function(g){return b.add(pv.Panel).data(function(){return d}).add(g).extend(this)}};pv.Layout.Rollup.prototype=pv.extend(pv.Layout.Network).property("directed",Boolean);
+pv.Layout.Rollup.prototype.x=function(b){this.$x=pv.functor(b);return this};pv.Layout.Rollup.prototype.y=function(b){this.$y=pv.functor(b);return this};
+pv.Layout.Rollup.prototype.buildImplied=function(b){function c(n){return i[n]+","+j[n]}if(!pv.Layout.Network.prototype.buildImplied.call(this,b)){var d=b.nodes,f=b.links,g=b.directed,h=d.length,i=[],j=[],k=0,l={},s={},p=pv.Mark.stack,q={parent:this};p.unshift(null);for(var m=0;m<h;m++){q.index=m;p[0]=d[m];i[m]=this.$x.apply(q,p);j[m]=this.$y.apply(q,p)}p.shift();for(m=0;m<d.length;m++){h=c(m);p=l[h];if(!p){p=l[h]=pv.extend(d[m]);p.index=k++;p.x=i[m];p.y=j[m];p.nodes=[]}p.nodes.push(d[m]) [...]
+f.length;m++){k=f[m].targetNode;d=l[c(f[m].sourceNode.index)];k=l[c(k.index)];h=!g&&d.index>k.index?k.index+","+d.index:d.index+","+k.index;(p=s[h])||(p=s[h]={sourceNode:d,targetNode:k,linkValue:0,links:[]});p.links.push(f[m]);p.linkValue+=f[m].linkValue}b.$rollup={nodes:pv.values(l),links:pv.values(s)}}};
+pv.Layout.Matrix=function(){pv.Layout.Network.call(this);var b,c,d,f,g,h=this.buildImplied;this.buildImplied=function(i){h.call(this,i);b=i.nodes.length;c=i.width/b;d=i.height/b;f=i.$matrix.labels;g=i.$matrix.pairs};this.link.data(function(){return g}).left(function(){return c*(this.index%b)}).top(function(){return d*Math.floor(this.index/b)}).width(function(){return c}).height(function(){return d}).lineWidth(1.5).strokeStyle("#fff").fillStyle(function(i){return i.linkValue?"#555":"#eee" [...]
+this;delete this.link.add;this.label.data(function(){return f}).left(function(){return this.index&1?c*((this.index>>1)+0.5):0}).top(function(){return this.index&1?0:d*((this.index>>1)+0.5)}).textMargin(4).textAlign(function(){return this.index&1?"left":"right"}).textAngle(function(){return this.index&1?-Math.PI/2:0});delete this.node};pv.Layout.Matrix.prototype=pv.extend(pv.Layout.Network).property("directed",Boolean);pv.Layout.Matrix.prototype.sort=function(b){this.$sort=b;return this};
+pv.Layout.Matrix.prototype.buildImplied=function(b){if(!pv.Layout.Network.prototype.buildImplied.call(this,b)){var c=b.nodes,d=b.links,f=this.$sort,g=c.length,h=pv.range(g),i=[],j=[],k={};b.$matrix={labels:i,pairs:j};f&&h.sort(function(m,n){return f(c[m],c[n])});for(var l=0;l<g;l++)for(var s=0;s<g;s++){var p=h[l],q=h[s];j.push(k[p+"."+q]={row:l,col:s,sourceNode:c[p],targetNode:c[q],linkValue:0})}for(l=0;l<g;l++){p=h[l];i.push(c[p],c[p])}for(l=0;l<d.length;l++){i=d[l];g=i.sourceNode.index [...]
+i=i.linkValue;k[g+"."+h].linkValue+=i;b.directed||(k[h+"."+g].linkValue+=i)}}};
+pv.Layout.Bullet=function(){pv.Layout.call(this);var b=this,c=b.buildImplied,d=b.x=pv.Scale.linear(),f,g,h,i,j;this.buildImplied=function(k){c.call(this,j=k);f=k.orient;g=/^left|right$/.test(f);h=pv.ramp("#bbb","#eee").domain(0,Math.max(1,j.ranges.length-1));i=pv.ramp("steelblue","lightsteelblue").domain(0,Math.max(1,j.measures.length-1))};(this.range=new pv.Mark).data(function(){return j.ranges}).reverse(true).left(function(){return f=="left"?0:null}).top(function(){return f=="top"?0:nu [...]
+"right"?0:null}).bottom(function(){return f=="bottom"?0:null}).width(function(k){return g?d(k):null}).height(function(k){return g?null:d(k)}).fillStyle(function(){return h(this.index)}).antialias(false).parent=b;(this.measure=new pv.Mark).extend(this.range).data(function(){return j.measures}).left(function(){return f=="left"?0:g?null:this.parent.width()/3.25}).top(function(){return f=="top"?0:g?this.parent.height()/3.25:null}).right(function(){return f=="right"?0:g?null:this.parent.width [...]
+"bottom"?0:g?this.parent.height()/3.25:null}).fillStyle(function(){return i(this.index)}).parent=b;(this.marker=new pv.Mark).data(function(){return j.markers}).left(function(k){return f=="left"?d(k):g?null:this.parent.width()/2}).top(function(k){return f=="top"?d(k):g?this.parent.height()/2:null}).right(function(k){return f=="right"?d(k):null}).bottom(function(k){return f=="bottom"?d(k):null}).strokeStyle("black").shape("bar").shapeAngle(function(){return g?0:Math.PI/2}).parent=b;(this.t [...]
+"left"?d(k):null}).top(function(k){return f=="top"?d(k):null}).right(function(k){return f=="right"?d(k):g?null:-6}).bottom(function(k){return f=="bottom"?d(k):g?-8:null}).height(function(){return g?6:null}).width(function(){return g?null:6}).parent=b};pv.Layout.Bullet.prototype=pv.extend(pv.Layout).property("orient",String).property("ranges").property("markers").property("measures").property("maximum",Number);pv.Layout.Bullet.prototype.defaults=(new pv.Layout.Bullet).extend(pv.Layout.pro [...]
+pv.Layout.Bullet.prototype.buildImplied=function(b){pv.Layout.prototype.buildImplied.call(this,b);var c=this.parent[/^left|right$/.test(b.orient)?"width":"height"]();b.maximum=b.maximum||pv.max([].concat(b.ranges,b.markers,b.measures));this.x.domain(0,b.maximum).range(0,c)};pv.Behavior={};
+pv.Behavior.drag=function(){function b(k){g=this.index;f=this.scene;var l=this.mouse();i=((h=k).fix=pv.vector(k.x,k.y)).minus(l);j={x:this.parent.width()-(k.dx||0),y:this.parent.height()-(k.dy||0)};f.mark.context(f,g,function(){this.render()});pv.Mark.dispatch("dragstart",f,g)}function c(){if(f){f.mark.context(f,g,function(){var k=this.mouse();h.x=h.fix.x=Math.max(0,Math.min(i.x+k.x,j.x));h.y=h.fix.y=Math.max(0,Math.min(i.y+k.y,j.y));this.render()});pv.Mark.dispatch("drag",f,g)}}function [...]
+null;f.mark.context(f,g,function(){this.render()});pv.Mark.dispatch("dragend",f,g);f=null}}var f,g,h,i,j;pv.listen(window,"mousemove",c);pv.listen(window,"mouseup",d);return b};
+pv.Behavior.point=function(b){function c(l,s){l=l[s];s={cost:Infinity};for(var p=0,q=l.visible&&l.children.length;p<q;p++){var m=l.children[p],n=m.mark,r;if(n.type=="panel"){n.scene=m;for(var t=0,x=m.length;t<x;t++){n.index=t;r=c(m,t);if(r.cost<s.cost)s=r}delete n.scene;delete n.index}else if(n.$handlers.point){n=n.mouse();t=0;for(x=m.length;t<x;t++){var u=m[t];r=n.x-u.left-(u.width||0)/2;u=n.y-u.top-(u.height||0)/2;var o=i*r*r+j*u*u;if(o<s.cost){s.distance=r*r+u*u;s.cost=o;s.scene=m;s.i [...]
+function d(){var l=c(this.scene,this.index);if(l.cost==Infinity||l.distance>k)l=null;if(g){if(l&&g.scene==l.scene&&g.index==l.index)return;pv.Mark.dispatch("unpoint",g.scene,g.index)}if(g=l){pv.Mark.dispatch("point",l.scene,l.index);pv.listen(this.root.canvas(),"mouseout",f)}}function f(l){if(g&&!pv.ancestor(this,l.relatedTarget)){pv.Mark.dispatch("unpoint",g.scene,g.index);g=null}}var g,h=null,i=1,j=1,k=arguments.length?b*b:900;d.collapse=function(l){if(arguments.length){h=String(l);swi [...]
+1;j=0;break;case "x":i=0;j=1;break;default:j=i=1;break}return d}return h};return d};
+pv.Behavior.select=function(){function b(j){g=this.index;f=this.scene;i=this.mouse();h=j;h.x=i.x;h.y=i.y;h.dx=h.dy=0;pv.Mark.dispatch("selectstart",f,g)}function c(){if(f){f.mark.context(f,g,function(){var j=this.mouse();h.x=Math.max(0,Math.min(i.x,j.x));h.y=Math.max(0,Math.min(i.y,j.y));h.dx=Math.min(this.width(),Math.max(j.x,i.x))-h.x;h.dy=Math.min(this.height(),Math.max(j.y,i.y))-h.y;this.render()});pv.Mark.dispatch("select",f,g)}}function d(){if(f){pv.Mark.dispatch("selectend",f,g);f [...]
+g,h,i;pv.listen(window,"mousemove",c);pv.listen(window,"mouseup",d);return b};
+pv.Behavior.resize=function(b){function c(k){h=this.index;g=this.scene;j=this.mouse();i=k;switch(b){case "left":j.x=i.x+i.dx;break;case "right":j.x=i.x;break;case "top":j.y=i.y+i.dy;break;case "bottom":j.y=i.y;break}pv.Mark.dispatch("resizestart",g,h)}function d(){if(g){g.mark.context(g,h,function(){var k=this.mouse();i.x=Math.max(0,Math.min(j.x,k.x));i.y=Math.max(0,Math.min(j.y,k.y));i.dx=Math.min(this.parent.width(),Math.max(k.x,j.x))-i.x;i.dy=Math.min(this.parent.height(),Math.max(k.y [...]
+this.render()});pv.Mark.dispatch("resize",g,h)}}function f(){if(g){pv.Mark.dispatch("resizeend",g,h);g=null}}var g,h,i,j;pv.listen(window,"mousemove",d);pv.listen(window,"mouseup",f);return c};
+pv.Behavior.pan=function(){function b(){g=this.index;f=this.scene;i=pv.vector(pv.event.pageX,pv.event.pageY);h=this.transform();j=1/(h.k*this.scale);if(k)k={x:(1-h.k)*this.width(),y:(1-h.k)*this.height()}}function c(){if(f){f.mark.context(f,g,function(){var l=h.translate((pv.event.pageX-i.x)*j,(pv.event.pageY-i.y)*j);if(k){l.x=Math.max(k.x,Math.min(0,l.x));l.y=Math.max(k.y,Math.min(0,l.y))}this.transform(l).render()});pv.Mark.dispatch("pan",f,g)}}function d(){f=null}var f,g,h,i,j,k;b.bou [...]
+Boolean(l);return this}return Boolean(k)};pv.listen(window,"mousemove",c);pv.listen(window,"mouseup",d);return b};
+pv.Behavior.zoom=function(b){function c(){var f=this.mouse(),g=pv.event.wheel*b;f=this.transform().translate(f.x,f.y).scale(g<0?1E3/(1E3-g):(1E3+g)/1E3).translate(-f.x,-f.y);if(d){f.k=Math.max(1,f.k);f.x=Math.max((1-f.k)*this.width(),Math.min(0,f.x));f.y=Math.max((1-f.k)*this.height(),Math.min(0,f.y))}this.transform(f).render();pv.Mark.dispatch("zoom",this.scene,this.index)}var d;arguments.length||(b=1/48);c.bound=function(f){if(arguments.length){d=Boolean(f);return this}return Boolean(d [...]
+pv.Geo=function(){};
+pv.Geo.projections={mercator:{project:function(b){return{x:b.lng/180,y:b.lat>85?1:b.lat<-85?-1:Math.log(Math.tan(Math.PI/4+pv.radians(b.lat)/2))/Math.PI}},invert:function(b){return{lng:b.x*180,lat:pv.degrees(2*Math.atan(Math.exp(b.y*Math.PI))-Math.PI/2)}}},"gall-peters":{project:function(b){return{x:b.lng/180,y:Math.sin(pv.radians(b.lat))}},invert:function(b){return{lng:b.x*180,lat:pv.degrees(Math.asin(b.y))}}},sinusoidal:{project:function(b){return{x:pv.radians(b.lng)*Math.cos(pv.radian [...]
+y:b.lat/90}},invert:function(b){return{lng:pv.degrees(b.x*Math.PI/Math.cos(b.y*Math.PI/2)),lat:b.y*90}}},aitoff:{project:function(b){var c=pv.radians(b.lng);b=pv.radians(b.lat);var d=Math.acos(Math.cos(b)*Math.cos(c/2));return{x:2*(d?Math.cos(b)*Math.sin(c/2)*d/Math.sin(d):0)/Math.PI,y:2*(d?Math.sin(b)*d/Math.sin(d):0)/Math.PI}},invert:function(b){var c=b.y*Math.PI/2;return{lng:pv.degrees(b.x*Math.PI/2/Math.cos(c)),lat:pv.degrees(c)}}},hammer:{project:function(b){var c=pv.radians(b.lng); [...]
+var d=Math.sqrt(1+Math.cos(b)*Math.cos(c/2));return{x:2*Math.SQRT2*Math.cos(b)*Math.sin(c/2)/d/3,y:Math.SQRT2*Math.sin(b)/d/1.5}},invert:function(b){var c=b.x*3;b=b.y*1.5;var d=Math.sqrt(1-c*c/16-b*b/4);return{lng:pv.degrees(2*Math.atan2(d*c,2*(2*d*d-1))),lat:pv.degrees(Math.asin(d*b))}}},identity:{project:function(b){return{x:b.lng/180,y:b.lat/90}},invert:function(b){return{lng:b.x*180,lat:b.y*90}}}};
+pv.Geo.scale=function(b){function c(m){if(!p||m.lng!=p.lng||m.lat!=p.lat){p=m;m=d(m);q={x:k(m.x),y:l(m.y)}}return q}function d(m){return j.project({lng:m.lng-s.lng,lat:m.lat})}function f(m){m=j.invert(m);m.lng+=s.lng;return m}var g={x:0,y:0},h={x:1,y:1},i=[],j=pv.Geo.projections.identity,k=pv.Scale.linear(-1,1).range(0,1),l=pv.Scale.linear(-1,1).range(1,0),s={lng:0,lat:0},p,q;c.x=function(m){return c(m).x};c.y=function(m){return c(m).y};c.ticks={lng:function(m){var n;if(i.length>1){var r [...]
+if(m==undefined)m=10;n=r.domain(i,function(t){return t.lat}).ticks(m);m=r.domain(i,function(t){return t.lng}).ticks(m)}else{n=pv.range(-80,81,10);m=pv.range(-180,181,10)}return m.map(function(t){return n.map(function(x){return{lat:x,lng:t}})})},lat:function(m){return pv.transpose(c.ticks.lng(m))}};c.invert=function(m){return f({x:k.invert(m.x),y:l.invert(m.y)})};c.domain=function(m,n){if(arguments.length){i=m instanceof Array?arguments.length>1?pv.map(m,n):m:Array.prototype.slice.call(ar [...]
+if(i.length>1){var r=i.map(function(x){return x.lng}),t=i.map(function(x){return x.lat});s={lng:(pv.max(r)+pv.min(r))/2,lat:(pv.max(t)+pv.min(t))/2};r=i.map(d);k.domain(r,function(x){return x.x});l.domain(r,function(x){return x.y})}else{s={lng:0,lat:0};k.domain(-1,1);l.domain(-1,1)}p=null;return this}return i};c.range=function(m,n){if(arguments.length){if(typeof m=="object"){g={x:Number(m.x),y:Number(m.y)};h={x:Number(n.x),y:Number(n.y)}}else{g={x:0,y:0};h={x:Number(m),y:Number(n)}}k.ran [...]
+l.range(h.y,g.y);p=null;return this}return[g,h]};c.projection=function(m){if(arguments.length){j=typeof m=="string"?pv.Geo.projections[m]||pv.Geo.projections.identity:m;return this.domain(i)}return m};c.by=function(m){function n(){return c(m.apply(this,arguments))}for(var r in c)n[r]=c[r];return n};arguments.length&&c.projection(b);return c};
diff --git a/spec/fixtures/rule-anchor.html b/spec/fixtures/rule-anchor.html
new file mode 100644
index 0000000..cf5a56c
--- /dev/null
+++ b/spec/fixtures/rule-anchor.html
@@ -0,0 +1,33 @@
+<html>
+  <head>
+    <title>Rule Anchor</title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+    <style type="text/css">span { display: block !important; }</style>
+  </head>
+  <body>
+    <script type="text/javascript+protovis">
+
+var vis = new pv.Panel()
+.width(400)
+.height(300)
+
+
+bar=vis.add(pv.Bar)
+.data(["left", "top", "right", "bottom", "center"])
+    .width(300)
+    .height(30)
+    .left(40)
+    .right(40)
+    .top(function() {return this.index*60}).fillStyle('red')
+
+var rule = bar.add(pv.Rule)
+
+rule.anchor(function(d) d).add(pv.Label)
+    .text(function(d, p) d);
+
+vis.render();
+
+    </script>
+  </body>
+</html>
+
diff --git a/spec/fixtures/rule_anchor.svg b/spec/fixtures/rule_anchor.svg
new file mode 100644
index 0000000..ccc6382
--- /dev/null
+++ b/spec/fixtures/rule_anchor.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="400" height="300"><g><rect x="40" width="300" height="30" fill="rgb(255,0,0)"/><rect x="40" y="60" width="300" height="30" fill="rgb(255,0,0)"/><rect x="40" y="120" width="300" height="30" fill="rgb(255,0,0)"/><rect x="40" y="180" width="300" height="30" fill="rgb(255,0,0)"/><rect x="40" y="240" width="300" height="30" fill="rgb(255,0,0)"/></g><g><line shape-rendering="crispEdges" x1="40" y [...]
diff --git a/spec/fixtures/stack-expand.html b/spec/fixtures/stack-expand.html
new file mode 100644
index 0000000..d0ea26d
--- /dev/null
+++ b/spec/fixtures/stack-expand.html
@@ -0,0 +1,41 @@
+<html>
+  <head>
+    <title>Stack</title>
+    <script type="text/javascript" src="protovis-d3.3.js"></script>
+    <script type="text/javascript" src="layers.js"></script>
+    <style type="text/css">
+
+body {
+  margin: 0;
+}
+
+    </style>
+  </head>
+  <body>
+    <script type="text/javascript+protovis">
+
+var w = 300,
+    h = 300,
+    n = 20, // number of layers
+    m = 75, // number of samples per layer
+    x = pv.Scale.linear(2, m - 1).range(0, w);
+
+var vis = new pv.Panel()
+    .width(w)
+    .height(h);
+
+vis.add(pv.Layout.Stack)
+    .layers(waves(n, m))
+    .order("inside-out")
+    .offset("expand")
+    .x(x.by(pv.index))
+    .y(pv.identity)
+  .layer.add(pv.Area)
+    .fillStyle(pv.ramp("#ada", "#656").domain(n, 0).by(pv.parent))
+    .strokeStyle("#797");
+
+vis.render();
+
+    </script>
+  </body>
+</html>
diff --git a/spec/fixtures/stack-silohouette.html b/spec/fixtures/stack-silohouette.html
new file mode 100644
index 0000000..5c7f869
--- /dev/null
+++ b/spec/fixtures/stack-silohouette.html
@@ -0,0 +1,41 @@
+<html>
+  <head>
+    <title>Stack</title>
+    <script type="text/javascript" src="protovis-d3.3.js"></script>
+    <script type="text/javascript" src="layers.js"></script>
+    <style type="text/css">
+
+body {
+  margin: 0;
+}
+
+    </style>
+  </head>
+  <body>
+    <script type="text/javascript+protovis">
+
+var w = 300,
+    h = 300,
+    n = 20, // number of layers
+    m = 75, // number of samples per layer
+    x = pv.Scale.linear(2, m - 1).range(0, w)
+    y = pv.Scale.linear(0,20).range(0,h/2.0)
+var vis = new pv.Panel()
+    .width(w)
+    .height(h);
+
+vis.add(pv.Layout.Stack)
+    .layers(waves(n, m))
+    .order("reverse")
+    .offset("silohouette")
+    .x(x.by(pv.index))
+    .y(function(d) {return y(d);})
+  .layer.add(pv.Area)
+    .fillStyle(pv.ramp("#ada", "#656").domain(n, 0).by(pv.parent))
+    .strokeStyle("#797");
+
+vis.render();
+
+    </script>
+  </body>
+</html>
diff --git a/spec/fixtures/stack-wiggle.html b/spec/fixtures/stack-wiggle.html
new file mode 100644
index 0000000..f7ff94a
--- /dev/null
+++ b/spec/fixtures/stack-wiggle.html
@@ -0,0 +1,41 @@
+<html>
+  <head>
+    <title>Stack</title>
+    <script type="text/javascript" src="protovis-d3.3.js"></script>
+    <script type="text/javascript" src="layers.js"></script>
+    <style type="text/css">
+
+body {
+  margin: 0;
+}
+
+    </style>
+  </head>
+  <body>
+    <script type="text/javascript+protovis">
+
+var w = 300,
+    h = 300,
+    n = 20, // number of layers
+    m = 75, // number of samples per layer
+    x = pv.Scale.linear(2, m - 1).range(0, w)
+    y = pv.Scale.linear(0,20).range(0,h/2.0)
+var vis = new pv.Panel()
+    .width(w)
+    .height(h);
+
+vis.add(pv.Layout.Stack)
+    .layers(waves(n, m))
+    .order("reverse")
+    .offset("wiggle")
+    .x(x.by(pv.index))
+    .y(function(d) {return y(d);})
+  .layer.add(pv.Area)
+    .fillStyle(pv.ramp("#ada", "#656").domain(n, 0).by(pv.parent))
+    .strokeStyle("#797");
+
+vis.render();
+
+    </script>
+  </body>
+</html>
diff --git a/spec/fixtures/stack_expand.svg b/spec/fixtures/stack_expand.svg
new file mode 100644
index 0000000..9f3995f
--- /dev/null
+++ b/spec/fixtures/stack_expand.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="300" height="300"><g><g><g><path d="M-8.333333333333332,150L-4.166666666666666,0L0,92.10125514573261L4.166666666666666,107.57920319685743L8.333333333333332,112.59361737505047L12.5,129.99309047456265L16.666666666666664,126.22521039818037L20.833333333333336,134.06499041151739L25,136.14009485051474L29.166666666666668,136.33967848415972L33.33333333333333,142.06670954564044L37.5,139.556241082722 [...]
diff --git a/spec/fixtures/stack_silohouette.svg b/spec/fixtures/stack_silohouette.svg
new file mode 100644
index 0000000..11da27b
--- /dev/null
+++ b/spec/fixtures/stack_silohouette.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="300" height="300"><g><g><g><path d="M-8.333333333333332,150L-4.166666666666666,148.2496533619141L0,145.57903051948747L4.166666666666666,142.27095925657576L8.333333333333332,138.55530652396936L12.5,134.61798799673383L16.666666666666664,130.0916154221892L20.833333333333336,125.57768875182055L25,121.16943376346882L29.166666666666668,116.93991678379825L33.33333333333333,112.94581959200374L37.5, [...]
diff --git a/spec/fixtures/stack_wiggle.svg b/spec/fixtures/stack_wiggle.svg
new file mode 100644
index 0000000..5fa87ea
--- /dev/null
+++ b/spec/fixtures/stack_wiggle.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="300" height="300"><g><g><g><path d="M-8.333333333333332,150L-4.166666666666666,148.2496533619141L0,146.11639426051354L4.166666666666666,143.73579917041062L8.333333333333332,141.3124885632521L12.5,139.01643580825584L16.666666666666664,136.81373025563462L20.833333333333336,134.85701330419985L25,133.21714764209383L29.166666666666668,131.94930556574937L33.33333333333333,131.09540993837012L37.5, [...]
diff --git a/spec/fixtures/svgscene.html b/spec/fixtures/svgscene.html
new file mode 100644
index 0000000..ec5a12d
--- /dev/null
+++ b/spec/fixtures/svgscene.html
@@ -0,0 +1,26 @@
+<html>
+  <head>
+    <title>Anchor</title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+  </head>
+  <body>
+    <script type="text/javascript+protovis">
+
+    var s0={left:1,top:2,visible:1,lineWidth:2.5},
+    s1={left:3,top:4,visible:1,lineWidth:2.5},
+    s2={left:5,top:6,visible:1,lineWidth:2.5},
+    s3={left:7,top:8,visible:1,lineWidth:2.5}
+    
+    document.write(pv.SvgScene.pathJoin(s0,s1,s2,s3))
+    
+    
+    var s0={left:1.5,top:2,visible:1,lineWidth:3},
+    s1={left:3.5,top:4,visible:1,lineWidth:3.5},
+    s2={left:5.5,top:6,visible:1,lineWidth:4},
+    s3={left:7.5,top:8,visible:1,lineWidth:4.5}
+    document.write("<br />")
+    document.write(pv.SvgScene.pathJoin(s0,s1,s2,s3))
+    
+    </script>
+  </body>
+</html>
diff --git a/spec/fixtures/tipsy.gif b/spec/fixtures/tipsy.gif
new file mode 100644
index 0000000..74eebae
Binary files /dev/null and b/spec/fixtures/tipsy.gif differ
diff --git a/spec/fixtures/wedge-anchor.html b/spec/fixtures/wedge-anchor.html
new file mode 100644
index 0000000..88bb28b
--- /dev/null
+++ b/spec/fixtures/wedge-anchor.html
@@ -0,0 +1,33 @@
+<html>
+  <head>
+    <title>Donut</title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+  </head>
+  <body>
+    <script type="text/javascript+protovis">
+
+    var data = pv.range(5).map(function(x) {return x;}),
+    w = 400,
+    h = 400,
+    r = w / 2,
+    t = 30,
+    a = pv.Scale.linear(0, pv.sum(data)).range(0, 2 * Math.PI);
+
+var vis = new pv.Panel()
+    .width(w)
+    .height(h);
+
+anchors=["outer","inner","start","center","end"]
+    
+vis.add(pv.Wedge)
+    .data(data)
+    .outerRadius(r)
+    .angle(a)
+    .anchor(function() { return anchors[this.index]}).add(pv.Label)
+    .text(function(d) {return anchors[this.index];})
+
+vis.render();
+
+    </script>
+  </body>
+</html>
diff --git a/spec/fixtures/wedge-donut.html b/spec/fixtures/wedge-donut.html
new file mode 100644
index 0000000..2f8d1fd
--- /dev/null
+++ b/spec/fixtures/wedge-donut.html
@@ -0,0 +1,35 @@
+<html>
+  <head>
+    <title>Donut</title>
+    <script type="text/javascript" src="protovis-r3.3.js"></script>
+  </head>
+  <body>
+    <script type="text/javascript+protovis">
+
+var data = pv.range(10).map(function(x) {return Math.abs(Math.sin(x))}),
+    w = 400,
+    h = 400,
+    r = w / 2,
+    t = 30,
+    a = pv.Scale.linear(0, pv.sum(data)).range(0, 2 * Math.PI);
+
+var vis = new pv.Panel()
+    .width(w)
+    .height(h);
+
+vis.add(pv.Wedge)
+    .data(data)
+    .innerRadius(r - t)
+    .outerRadius(r)
+    .angle(a)
+    .title(function(d) d)
+  .anchor("outer").add(pv.Label)
+    .visible(function(d) d > .05)
+    .textMargin(t + 5)
+    .text(function(d) d.toFixed(2));
+
+vis.render();
+
+    </script>
+  </body>
+</html>
diff --git a/spec/fixtures/wedge_anchor.svg b/spec/fixtures/wedge_anchor.svg
new file mode 100644
index 0000000..c1c8bd9
--- /dev/null
+++ b/spec/fixtures/wedge_anchor.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="400" height="400"><g><path transform="translate(200, 200)" d="M1.2246467991473532e-14,-200A200,200 0 0,1 1.2246467991473532e-14,-200L0,0Z" fill="rgb(31,119,180)" fill-rule="evenodd"/><path transform="translate(200, 200)" d="M1.2246467991473532e-14,-200A200,200 0 0,1 117.55705045849463,-161.80339887498948L0,0Z" fill="rgb(174,199,232)" fill-rule="evenodd"/><path transform="translate(200, 200) [...]
diff --git a/spec/fixtures/wedge_donut.svg b/spec/fixtures/wedge_donut.svg
new file mode 100644
index 0000000..66a53d3
--- /dev/null
+++ b/spec/fixtures/wedge_donut.svg
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="400" height="400"><g><a title="0"><path transform="translate(200, 200)" d="M1.2246467991473532e-14,-200A200,200 0 0,1 1.2246467991473532e-14,-200L1.0409497792752502e-14,-170A170,170 0 0,0 1.0409497792752502e-14,-170Z" fill="rgb(31,119,180)" fill-rule="evenodd"/></a><a title="0.8414709848078965"><path transform="translate(200, 200)" d="M1.2246467991473532e-14,-200A200,200 0 0,1 155.321749844 [...]
diff --git a/spec/flatten_spec.rb b/spec/flatten_spec.rb
new file mode 100644
index 0000000..af08331
--- /dev/null
+++ b/spec/flatten_spec.rb
@@ -0,0 +1,47 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Flatten do
+  before do
+    @data={
+      "Genesis"=>{
+        "Live"=>{
+          "Genesis Live"=>1973,
+          "Seconds Out"=>1977
+        },
+        "Studio"=>{
+          "Nursery Cryme"=>1971,
+          "Foxtrot"=>1972
+        }
+      },
+      "Rush"=>{
+        "Studio"=>{
+          "Permanent Waves"=>1980,
+          "Moving Pictures"=>1981
+        },
+        "Live"=>{
+          "Exit...Stage Left"=>1981,
+          "A Show of Hands"=>1989
+        }
+      },
+    }
+    @flatten = Rubyvis.flatten(@data)
+    @flatten.key("band").key("type").key("album").key("year")
+
+  end
+  it "should return correct array" do
+    sorting=lambda {|a,b|
+      f1=a["band"]<=>a["band"]
+      f2=a["type"]<=>a["type"]
+      f3=a["album"]<=>a["album"]
+      f4=a["year"]<=>a["year"]
+      f1!=0 ? f1 : (f2!=0 ? f2 :(f3!=0 ? f3 : (f4!=0 ? f4 : 0)))
+    }
+    expected=[{"band"=>"Genesis", "type"=>"Live", "album"=>"Genesis Live", "year"=>1973}, {"band"=>"Genesis", "type"=>"Live", "album"=>"Seconds Out", "year"=>1977}, {"band"=>"Genesis", "type"=>"Studio", "album"=>"Nursery Cryme", "year"=>1971}, {"band"=>"Genesis", "type"=>"Studio", "album"=>"Foxtrot", "year"=>1972}, {"band"=>"Rush", "type"=>"Studio", "album"=>"Permanent Waves", "year"=>1980}, {"band"=>"Rush", "type"=>"Studio", "album"=>"Moving Pictures", "year"=>1981}, {"band"=>"Rush", "t [...]
+    
+    @flatten.array.sort(&sorting).should eq expected
+  end
+  it "other example" do
+    @flatten.leaf(lambda {|f| f.is_a? Numeric})
+    expected=[{:keys=>["Genesis", "Live", "Genesis Live"], :value=>1973}, {:keys=>["Genesis", "Live", "Seconds Out"], :value=>1977}, {:keys=>["Genesis", "Studio", "Nursery Cryme"], :value=>1971}, {:keys=>["Genesis", "Studio", "Foxtrot"], :value=>1972}, {:keys=>["Rush", "Studio", "Permanent Waves"], :value=>1980}, {:keys=>["Rush", "Studio", "Moving Pictures"], :value=>1981}, {:keys=>["Rush", "Live", "Exit...Stage Left"], :value=>1981}, {:keys=>["Rush", "Live", "A Show of Hands"], :value=>1989}]
+    @flatten.array.should eql expected
+  end
+end
diff --git a/spec/histogram_spec.rb b/spec/histogram_spec.rb
new file mode 100644
index 0000000..aeffc78
--- /dev/null
+++ b/spec/histogram_spec.rb
@@ -0,0 +1,28 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Histogram do
+  describe "bins" do
+    before do 
+      data = Rubyvis.range(0, 10, 0.1).map {|x| 
+        Math.sin(x)
+      }
+      @hist=Rubyvis::Histogram.new(data)
+      @bins=@hist.bins
+    end
+    it "size should be correct" do
+      @bins.size.should eq 8
+    end
+    it "bin.x should be correct" do
+      @bins.map {|b| b.x}.should eq [-0.8, -0.6, -0.4, -0.2, 0, 0.2,0.4, 0.6]
+    end
+    it "bin.dx should be correct" do
+      @bins.map {|b| b.dx}.should eq [0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2]
+    end
+    it "bin.y should be correct" do
+      @bins.map {|b| b.y}.should eq [19,5,6,7,8,8,11,36]
+    end
+    it "bin.y should be correct using frequency=false" do
+      @hist.frequency=false
+      @hist.bins.map {|b| b.y}.should eq [0.19,0.05,0.06,0.07,0.08,0.08,0.11,0.36]
+    end
+  end
+end
\ No newline at end of file
diff --git a/spec/image_spec.rb b/spec/image_spec.rb
new file mode 100644
index 0000000..942577d
--- /dev/null
+++ b/spec/image_spec.rb
@@ -0,0 +1,27 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Image do
+
+  include Rubyvis::GeneralSpec
+
+  it "Rubyvis.Image be the same as Rubyvis::Image" do
+    Rubyvis.Image.should eql Rubyvis::Image
+  end
+  
+  it "should render correctly" do
+    w = 400
+    h = 400
+    
+    vis = Rubyvis::Panel.new().
+      width(w).
+      height(h).
+      margin(20).
+      stroke_style("#ccc");
+    
+    vis.add(Rubyvis::Image).url('fixtures/tipsy.gif')
+    vis.render()
+    
+    pv_out=fixture_svg_read("image.svg")
+    vis.to_svg.should have_same_svg_elements(pv_out)
+  end
+   
+end
diff --git a/spec/internal_spec.rb b/spec/internal_spec.rb
new file mode 100644
index 0000000..37fd55a
--- /dev/null
+++ b/spec/internal_spec.rb
@@ -0,0 +1,151 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe "Rubyvis module methods" do
+  describe "from pv.js" do
+    it "method identify should always return the same value" do
+      f=Rubyvis.identity
+      a="a"
+      f.js_call(a, 5).should==5
+    end
+    it "method index should return index method from a object" do
+      o1=Rubyvis.o_index(1)
+      o2=Rubyvis.o_index(10)
+      Rubyvis.index.js_call(o1,1,2).should==1
+      Rubyvis.index.js_call(o2,1,2).should==10
+    end
+  end
+  describe "from pv-internal.js" do 
+    it "should create a infinite succesion with id" do
+      f=Rubyvis.id
+      Rubyvis.id.should==f+1
+    end
+    it "should return a lambda with functor" do
+      Rubyvis.functor(5).call.should==5
+    end
+  end
+  describe "from data/Arrays.js" do 
+    it "map method should map an array using a index based object" do
+      f=lambda {|d| "#{self.index}-#{d}"}
+      i=%w{a b c}
+      o=%w{0-a 1-b 2-c}
+      Rubyvis.map(i).should==i
+      Rubyvis.map(i,f).should==o
+    end
+    it "repeat method should repeat the specified array n times" do
+      Rubyvis.repeat([1,2]).should==[1,2,1,2]
+      Rubyvis.repeat([1,2],3).should==[1,2,1,2,1,2]
+    end
+    it "cross method should return an array of all posible pairs of element" do
+      Rubyvis.cross([1,2],[3,4]).should==[[1,3],[1,4],[2,3],[2,4]]
+    end
+    it "blend method should concatenates the arrays into a single array" do
+      Rubyvis.blend([[1,2,3],[4,5,6],[7,8,9]]).should==(1..9).to_a
+    end
+    it "transpose method should returns a transposed array of arrays" do
+      Rubyvis.transpose([[1,2,3],[4,5,6]]).should==[[1,4],[2,5],[3,6]]
+    end
+    it "normalize method should returns a normalized copy of array" do
+      Rubyvis.normalize([1,1,3]).should==[0.2,0.2,0.6]
+      a=%w{aa ccc ddddd}
+      f=lambda {|e| e.size}
+      Rubyvis.normalize(a,f).should==[0.2,0.3,0.5]
+    end
+    it "permute method allows to permute the order of elements" do
+      Rubyvis.permute(%w{a b c},[1,2,0]).should==%w{b c a}
+      f=lambda {|e| [self.index,e]}
+      Rubyvis.permute(%w{a b c},[1,2,0],f).should==[[1,"b"],[2,"c"],[0,"a"]]
+    end
+    it "numerate should  map from key to index for the specified keys array" do
+      Rubyvis.numerate(["a", "b", "c"]).should=={"a"=>0,"b"=>1,"c"=>2}
+    end
+    it "method uniq returns the unique elements in the specified array" do
+      Rubyvis.uniq(["a", "b", "c","c"]).should==["a","b","c"]
+      Rubyvis.uniq(["a", "b", "c","c"], lambda{|e| e*2}).should==["aa","bb","cc"]
+    end
+    it "method search should return correct values" do
+      a=(0..9).to_a
+      Rubyvis.search(a,1).should==1
+      Rubyvis.search(a,20).should==-11
+      Rubyvis.search(a,5.5).should==-7
+    end
+    it "method search_index should return correct values" do
+      a=(0..9).to_a
+      Rubyvis.search_index(a,1).should==1
+      Rubyvis.search_index(a,20).should==10
+      Rubyvis.search_index(a,5.5).should==6
+    end
+  end
+  describe "from data/Numbers.js" do
+    it "method range should create range of numbers" do
+      Rubyvis.range(1,10).should==[1,2,3,4,5,6,7,8,9]
+      Rubyvis.range(1,10,0.5).should==[1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5]
+      Rubyvis.range(1,10,3).should==[1,4,7]  
+      lambda {Rubyvis.range(1,10,0)}.should raise_exception
+    end
+    it "method random returns a random number between values" do
+      srand(10)
+      100.times.map{ Rubyvis.random(5)}.uniq.sort.should==(0..4).to_a
+      100.times.map{ Rubyvis.random(1,5)}.uniq.sort.should==(1..4).to_a
+      100.times.map{ Rubyvis.random(1,3,0.5)}.uniq.sort.should== [1.0,1.5,2.0,2.5]
+    end
+    it "methods sum returns a sum" do
+      Rubyvis.sum([1,2,3,4]).should==(1+2+3+4)
+      Rubyvis.sum(%w{1 4 3 2 5}, lambda {|v| v.to_i * self.index}).should==(4*1 + 3*2 + 2*3 + 5*4)
+    end
+    it "method max returns maximum value" do
+      Rubyvis.max([1,2,3,4]).should==4
+      Rubyvis.max([1,2,3,4], Rubyvis.index).should==3
+      Rubyvis.max(%w{1 4 3 2 5}, lambda {|v| v.to_i * self.index}).should==20
+    end
+    it "method max_index returns maximum value index" do
+      Rubyvis.max_index([1,2,4,3]).should==2
+      Rubyvis.max_index(%w{1 4 3 2 5}, lambda {|v| v.to_i * self.index}).should==4
+    end
+    it "method min returns minimum value" do
+      Rubyvis.min([1,2,3,4]).should==1
+      Rubyvis.min([1,2,3,4], Rubyvis.index).should==0
+      Rubyvis.min(%w{2 0 3 2 5}, lambda {|v| v.to_i + self.index}).should==1
+    end
+    it "method min_index returns minimum value index" do
+      Rubyvis.min_index([1,2,4,-1]).should==3
+      Rubyvis.min_index(%w{1 4 3 2 5}, lambda {|v| v.to_i * self.index}).should==0
+    end
+    it "method mean returns mean of values" do
+      a,b,c,d=rand,rand,rand,rand
+      #Rubyvis.mean([a,b,c,d]).should==(a+b+c+d).quo(4)
+      Rubyvis.mean([a,b,c,d].map {|x| x.to_s}, lambda {|v| v.to_f+1}).should==(a+b+c+d).quo(4)+1
+    end
+    it "method median returns median of values" do
+      Rubyvis.median([1,2,4,3]).should==2.5
+      Rubyvis.median([1,3,2,5,3]).should==3
+      Rubyvis.median([1,3,2,5,3].map {|v| v.to_s}, lambda {|v| v.to_f}).should==3
+    end
+    it "method variance returns sum of squares" do
+      Rubyvis.variance([5,7,9,11]).should==20
+      Rubyvis.variance([5,7,9,11], lambda {|x| x+self.index}).should==45
+    end
+    it "method deviation returns standard deviation" do
+      Rubyvis.deviation([5,7,9,11]).should be_within( 0.001).of(2.581)
+    end
+    it "method log" do
+      Rubyvis.log(5,4).should be_within( 0.001).of(1.16)
+    end
+    it "method log_symmetric" do
+      Rubyvis.log_symmetric(-5,4).should be_within( 0.001).of(-1.16)
+    end
+    it "method log_adjusted" do
+      Rubyvis.log_adjusted(6,10).should be_within( 0.001).of(0.806)
+    end
+    it "method log_floor" do
+      Rubyvis.log_floor(-5,4).should be_within( 0.001).of(16)
+    end
+    it "method log_ceil" do
+      Rubyvis.log_ceil(-5,4).should be_within( 0.001).of(-4)
+    end
+    it "method dict" do
+      Rubyvis.dict(["one", "three", "seventeen"], lambda {|s| s.size}).should=={"one"=> 3, "three"=> 5, "seventeen"=> 9}
+      Rubyvis.dict(["one", "three", nil, "seventeen"], lambda {|s| s.size}).should=={"one"=> 3, "three"=> 5, "seventeen"=> 9}
+      
+    end
+  end
+  
+end
diff --git a/spec/javascript_behaviour_spec.rb b/spec/javascript_behaviour_spec.rb
new file mode 100644
index 0000000..6e939c2
--- /dev/null
+++ b/spec/javascript_behaviour_spec.rb
@@ -0,0 +1,64 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe "Javascript compatibility" do
+  it "extends Proc with js_apply and js_call" do
+    f=lambda {|a,b| a+b}
+    f.should respond_to(:js_apply)
+    f.should respond_to(:js_call)
+  end
+  it "lambdas should respond correctly to js_call with same numbers of arguments and parameters" do
+    o=OpenStruct.new :x=>15
+    f=lambda {|m1,m2| "#{m1}-#{m2}-#{self.x}"}
+    f.js_call(o,"a","b").should=="a-b-15"
+  end
+  it "lambdas should respond correctly to js_call without arguments" do
+    o=OpenStruct.new :x=>15    
+    f=lambda { self.x.to_s}
+    f.js_call(o).should=="15"    
+  end
+  it "lambdas should respond correctly to js_call with different number or arguments" do
+    o=OpenStruct.new :x=>15    
+    f=lambda {|a,b,c| [a,b,c]}
+    f.js_call(o,1).should==[1,nil,nil]
+    f.js_call(o,1,2,3,4).should==[1,2,3]
+  end
+  context "js_call using lambda with variable arguments" do
+    before do
+      @o=OpenStruct.new :x=>15    
+      @f=lambda {|a,b,*c| {:a=>a, :b=>b, :c=>c}}
+    end
+    it "should work without 0 parameters" do
+      @f.js_call(@o).should=={:a=>nil, :b=>nil, :c=>[]}
+    end
+    it "should work with required parameter and 0 optional" do
+      @f.js_call(@o,1,2).should=={:a=>1, :b=>2, :c=>[]}
+    end
+    it "should work with required and optional parameters" do
+      @f.js_call(@o,1,2,3,4).should=={:a=>1, :b=>2, :c=>[3,4]}
+    end
+  end
+  it "lambdas should respond correctly to js_apply" do
+    o=OpenStruct.new :x=>15
+    f=lambda {|m1,m2| "#{m1}-#{m2}-#{self.x}"}
+    f.js_apply(o, ["a","b"]).should=="a-b-15"
+  end
+  it "lambdas should respond correctly to js_apply with empty arguments" do
+    o=OpenStruct.new :x=>15
+    f=lambda { "#{self.x}"}
+    f.js_apply(o, []).should=="15"
+    f.js_apply(o, [1]).should=="15"
+
+  end
+  
+  it "lambdas should respond correctly to js_call with fewer parameters" do
+    o=OpenStruct.new :x=>15    
+    f=lambda {|a,b,c| [a,b,c]}
+    f.js_apply(o,[1]).should==[1,nil,nil]
+  end
+  it "lambdas should respond correctly to js_call with more parameters" do
+    o=OpenStruct.new :x=>15    
+    f=lambda {|a,b,c| [a,b,c]}    
+    f.js_apply(o,[1,2,3,4]).should==[1,2,3]    
+  end
+  
+  
+end
\ No newline at end of file
diff --git a/spec/label_spec.rb b/spec/label_spec.rb
new file mode 100644
index 0000000..9836afc
--- /dev/null
+++ b/spec/label_spec.rb
@@ -0,0 +1,41 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+  describe Rubyvis::Label do
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :cursor, :data, :events, :font, :id, :left, :reverse, :right, :text, :text_align, :text_angle, :text_baseline, :text_decoration, :text_margin, :text_shadow, :text_style, :title, :top, :visible].inject({}) {|ac, v| ac[v]=true; ac}
+    
+    Rubyvis::Label.properties.should==props
+  end
+  it "should return correct defaults" do
+    props=Rubyvis::Bar.defaults._properties
+    props.size.should==2
+    props[0].name.should==:line_width
+    props[0].value.should==1.5
+    props[1].name.should==:fill_style
+    props[1].value.should be_instance_of Proc
+    Rubyvis::Bar.defaults.proto.should be_instance_of Rubyvis::Mark
+    
+  end
+  context "on a Panel" do 
+    before do
+      #Rubyvis.clear_document
+    @h=100
+    @w=200
+    @vis = Rubyvis.Panel.new.width(@w).height(@h)
+    @vis.add(pv.Bar).data([1,2]).width(20).height(lambda {|d| d * 80}).bottom(0).left(lambda {self.index * 25}).add(pv.Label)
+    end
+    it "should bould propertly" do
+      @vis.render
+      s=@vis.to_svg
+      #p s
+      #File.open("test.svg","w") {|f| f.puts s}
+
+      doc=Nokogiri::XML(s)
+      
+      attribs=doc.xpath("//xmlns:text").map {|v|
+      [v.attributes['y'].value, v.attributes['transform'].value, v.text] }
+      attribs.should==[["-3","translate(0,100)","1"],["-3","translate(25,100)","2"]]
+    end    
+  end  
+  
+  
+end
\ No newline at end of file
diff --git a/spec/layout_arc_spec.rb b/spec/layout_arc_spec.rb
new file mode 100644
index 0000000..0e07924
--- /dev/null
+++ b/spec/layout_arc_spec.rb
@@ -0,0 +1,68 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Layout::Arc do
+  include Rubyvis::LayoutSpec
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :canvas, :cursor, :data, :directed, :events, :fill_style, :height, :id, :left, :line_width, :links, :nodes, :orient, :overflow, :reverse, :right, :stroke_style, :title, :top, :transform, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Layout::Arc.properties.should==props 
+  end
+  it "should be called using Rubyvis.Layout.Arc" do
+    Rubyvis.Layout.Arc.should eql Rubyvis::Layout::Arc
+  end  
+  describe "rendered" do
+    before do
+      
+      
+      
+      
+      w = 300
+      h = 100
+      
+      color=Rubyvis::Colors.category19
+      
+      @vis = Rubyvis::Panel.new().
+        width(w).
+        height(h).
+        bottom(50).
+        left(0)
+      
+      mat=@vis.add(Rubyvis::Layout::Arc).
+        nodes(net_nodes).links(net_links).
+        sort(lambda {|a,b| a.group<=>b.group})
+      
+      mat.link.add(Rubyvis::Line).
+      antialias(false).
+      line_width(1)
+      
+      mat.node.add(Rubyvis::Dot).
+      shape_size(10).
+      fill_style(lambda {|l| color[l.group]})
+      
+      mat.node_label.add(Rubyvis::Label).
+      text_style(lambda {|l| color[l.group]})
+      
+      @vis.render
+
+      svg_out=fixture_svg_read("layout_arc.svg")
+      @rv_svg=Nokogiri::XML(@vis.to_svg)
+      @pv_svg=Nokogiri::XML(svg_out)
+    end
+    
+    it "should render correct number of clipaths" do
+      
+      @rv_svg.xpath("//xmlns:path").size.should eq @pv_svg.xpath("//path").size
+    end
+    it "should render equal paths (links)" do
+      pv_paths=@pv_svg.xpath("//path")
+      @rv_svg.xpath("//xmlns:path").each_with_index {|rv_path,i|
+        rv_path.should have_path_data_close_to pv_paths[i]['d']
+      }
+    end
+    it "should render equal dots (nodes)" do
+      pv_circles=@pv_svg.xpath("//circle")
+      @rv_svg.xpath("//xmlns:circle").each_with_index {|rv_circle,i|
+        rv_circle.should have_same_position pv_circles[i]
+      }
+      
+    end
+  end
+end
diff --git a/spec/layout_cluster_spec.rb b/spec/layout_cluster_spec.rb
new file mode 100644
index 0000000..ad6a951
--- /dev/null
+++ b/spec/layout_cluster_spec.rb
@@ -0,0 +1,53 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Layout::Cluster do
+  include Rubyvis::LayoutSpec
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :canvas, :cursor, :data, :events, :fill_style,:group,  :height, :id, :inner_radius, :left, :line_width, :links,  :nodes,   :orient, :outer_radius, :overflow, :reverse, :right, :stroke_style, :title, :top, :transform, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Layout::Cluster.properties.should==props 
+  end
+  it "should be called using Rubyvis.Layout.Cluster" do
+    Rubyvis.Layout.Cluster.should eql Rubyvis::Layout::Cluster
+  end
+  describe "html tests" do
+    
+    before  do
+      color=Rubyvis.Colors.category19
+      w=400
+      h=400
+      
+      @vis = Rubyvis.Panel.new().
+        width(w).
+        height(h).
+        top(20).
+        bottom(10).
+        left(10)
+      
+      @cluster = @vis.add(Rubyvis::Layout::Cluster).
+      nodes(hier_nodes_big).
+      orient("top")
+      
+      @cluster.node.add(Rubyvis::Dot).
+      fill_style(lambda {|d| color[d.node_value]}).
+      stroke_style("black").
+      line_width(1).
+      antialias(false)
+      
+      @cluster.link.add(Rubyvis::Line)
+      
+      @cluster.node_label.add(Rubyvis::Label).
+        text(lambda {|d| d.node_name})
+    end
+    it "should render correctly 'cluster.html' custom test" do
+      @vis.render
+      @pv_out=fixture_svg_read("layout_cluster.svg")
+      File.open("test.svg","w") {|fp| fp.write(@vis.to_svg)}
+      @vis.to_svg.should have_same_svg_elements(@pv_out)
+    end
+    it "should render correctly 'cluster_left_group_2.html' custom test" do
+      @cluster.orient("left").group(2)
+      @vis.render
+      @pv_out=fixture_svg_read("layout_cluster_left_group_2.svg")
+      @vis.to_svg.should have_same_svg_elements(@pv_out)
+    end
+  end
+end
diff --git a/spec/layout_grid_spec.rb b/spec/layout_grid_spec.rb
new file mode 100644
index 0000000..d92b19b
--- /dev/null
+++ b/spec/layout_grid_spec.rb
@@ -0,0 +1,40 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Layout::Grid do
+  include Rubyvis::LayoutSpec
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :canvas, :cols, :cursor, :data, :events, :fill_style, :height,  :id, :left, :line_width, :overflow, :reverse, :right, :rows, :stroke_style, :title, :top, :transform, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Layout::Grid.properties.should==props
+  end
+  it "Rubyvis.Layout.Grid be the same as Rubyvis::Layout::Grid" do
+    Rubyvis.Layout.Grid.should eql Rubyvis::Layout::Grid
+  end
+  it "should render equal to protovis 'layout_grid.html' test" do
+   
+    vis = pv.Panel.new().
+      data(["A"]).
+      width(800).
+      height(800).
+      margin(10).
+      fill_style("#eee").
+    stroke_style("#ccc");
+
+    vis.add(Rubyvis::Layout::Grid).
+      rows(3).
+      cols(3).
+      cell.add(Rubyvis::Layout::Grid).
+      rows(Rubyvis.index).
+      cols(Rubyvis.index).
+      cell.add(Rubyvis::Bar).
+      stroke_style("#fff").
+    anchor("center").add(Rubyvis::Label).
+      textStyle("rgba(255, 255, 255, .4)").
+      font("24px sans");
+
+vis.render();
+    
+    
+    pv_out=fixture_svg_read("layout_grid.svg")
+    vis.to_svg.should have_same_svg_elements(pv_out)
+  end  
+  
+end
\ No newline at end of file
diff --git a/spec/layout_horizon_spec.rb b/spec/layout_horizon_spec.rb
new file mode 100644
index 0000000..d01a2cc
--- /dev/null
+++ b/spec/layout_horizon_spec.rb
@@ -0,0 +1,59 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Layout::Horizon do
+  include Rubyvis::LayoutSpec
+  
+  it "should have correct properties" do
+    props=[:antialias, :background_style, :bands,  :bottom, :canvas, :cursor, :data, :events, :fill_style, :height, :id, :left, :line_width, :mode, :negative_style, :overflow, :positive_style, :reverse, :right, :stroke_style, :title, :top, :transform, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Layout::Horizon.properties.should==props 
+  end
+  it "should be called using Rubyvis.Layout.Horizon" do
+    Rubyvis.Layout.Horizon.should eql Rubyvis::Layout::Horizon
+  end
+  describe "rendered" do
+    before do
+      @data = Rubyvis.range(-5, 5, 0.1).map {|d|
+        OpenStruct.new({:x=> d ,  :y=> d**2-10});
+      }
+      
+      
+      
+      w = 400
+      h = 100
+      x = Rubyvis::Scale.linear(@data, lambda {|d| d.x}).range(0, w)
+      y = Rubyvis::Scale.linear(@data, lambda {|d| d.y}).range(-50, h*2);
+      
+      #/* The root panel. */
+      @vis = pv.Panel.new().width(w).height(h*2+20).bottom(20).left(20).right(10).top(5)
+
+      
+      
+      @pan = @vis.add(Rubyvis::Panel).
+      height(80).
+      top(30)  
+      
+      @pan.add(Rubyvis::Layout::Horizon).
+      bands(3).
+      band.add(Rubyvis::Area).
+      data(@data).
+      left(lambda {|d| x[d.x]}).
+      height(lambda {|d| y[d.y]})
+      @vis.render
+      
+      html_out=fixture_svg_read("layout_horizon.svg")
+      @rv_svg=Nokogiri::XML(@vis.to_svg)
+      @pv_svg=Nokogiri::XML(html_out)
+    end
+    
+    it "should render correct number of clipaths" do
+      
+      @rv_svg.xpath("//xmlns:clipPath[@id]").size.should eq @pv_svg.xpath("//clippath[@id]").size
+    end
+    it "should render equal paths" do
+      pv_paths=@pv_svg.xpath("//path")
+      @rv_svg.xpath("//xmlns:path").each_with_index {|rv_path,i|
+        rv_path.should have_path_data_close_to pv_paths[i]['d']
+        rv_path['fill'].should eq pv_paths[i]['fill']
+      }
+    end
+  end
+end
diff --git a/spec/layout_indent_spec.rb b/spec/layout_indent_spec.rb
new file mode 100644
index 0000000..184fe1a
--- /dev/null
+++ b/spec/layout_indent_spec.rb
@@ -0,0 +1,53 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Layout::Indent do
+  include Rubyvis::LayoutSpec
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :breadth, :canvas, :cursor, :data, :depth, :events, :fill_style, :height, :id, :left, :line_width, :links,  :nodes,  :overflow, :reverse, :right, :stroke_style, :title, :top, :transform, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Layout::Indent.properties.should==props 
+  end
+  it "should be called using Rubyvis.Layout.Indent" do
+    Rubyvis.Layout.Indent.should eql Rubyvis::Layout::Indent
+  end  
+  describe "rendered" do
+    before do
+    color=pv.Colors.category19
+    w=200
+    h=200
+    
+    @vis = pv.Panel.new().
+      width(w).
+      height(h).
+      top(20).
+      bottom(10).
+      left(10)
+    
+    indent = @vis.add(pv.Layout.Indent).
+    nodes(hier_nodes_big).
+    breadth(10)
+    
+    indent.node.add(pv.Dot).
+    fill_style(lambda {|d| color[d.node_value]}).
+    stroke_style("black").
+    line_width(1).
+    antialias(false)
+    indent.link.add(Rubyvis::Line) 
+    indent.node_label.add(pv.Label).
+    text(lambda {|d| d.node_value})
+    
+    
+    @vis.render
+    
+    html_out=fixture_svg_read("layout_indent.svg")
+    @rv_svg=Nokogiri::XML(@vis.to_svg)
+    @pv_svg=Nokogiri::XML(html_out)
+    end
+    
+    it "should render equal nodes (circles)" do
+      pv_rects=@pv_svg.xpath("//circle")
+      @rv_svg.xpath("//xmlns:circle").each_with_index {|rv_rect,i|
+        rv_rect.should have_same_position pv_rects[i]
+      }
+      
+    end
+  end
+end
diff --git a/spec/layout_matrix_spec.rb b/spec/layout_matrix_spec.rb
new file mode 100644
index 0000000..83b3cf1
--- /dev/null
+++ b/spec/layout_matrix_spec.rb
@@ -0,0 +1,53 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Layout::Matrix do
+  include Rubyvis::LayoutSpec
+  
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :canvas, :cursor, :data, :directed, :events, :fill_style, :height, :id, :left, :line_width, :links, :nodes, :overflow, :reverse, :right, :stroke_style, :title, :top, :transform, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Layout::Matrix.properties.should==props 
+  end
+  describe "rendered" do
+    before do   
+      w = 700
+      h = 700
+      
+      color=Rubyvis::Colors.category19()
+      @vis = Rubyvis::Panel.new().
+        width(w).
+        height(h).
+        top(50).
+        left(50)
+      
+      mat=@vis.add(Rubyvis::Layout.Matrix).
+directed(true).
+nodes(net_nodes).links(net_links).
+sort(lambda {|a,b| a.group<=>b.group})
+      
+      mat.link.add(pv.Bar).
+      fill_style(lambda {|l| l.link_value!=0 ? 
+      ((l.target_node.group==l.source_node.group) ? color[l.sourceNode] : "#555") : "#eee"}).
+      antialias(false).
+      line_width(1)
+      mat.node_label.add(Rubyvis::Label).
+      text_style(color)
+      @vis.render
+      
+      html_out=fixture_svg_read("layout_matrix.svg")
+      @rv_svg=Nokogiri::XML(@vis.to_svg)
+      @pv_svg=Nokogiri::XML(html_out)
+    end
+    
+    it "should render correct number of rects(links)" do
+      @rv_svg.xpath("//xmlns:rect").size.should eq @pv_svg.xpath("//rect").size
+    end
+    it "should render equal intersections (links)" do
+      pv_rects=@pv_svg.xpath("//rect")
+      @rv_svg.xpath("//xmlns:rect").each_with_index {|rv_rect,i|
+        rv_rect.should have_same_position pv_rects[i]
+      }
+      
+    end
+    
+    
+  end
+end
diff --git a/spec/layout_pack_spec.rb b/spec/layout_pack_spec.rb
new file mode 100644
index 0000000..f26d33b
--- /dev/null
+++ b/spec/layout_pack_spec.rb
@@ -0,0 +1,49 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Layout::Pack do
+  include Rubyvis::LayoutSpec
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :canvas, :cursor, :data, :events, :fill_style, :height, :id, :left, :line_width, :links,  :nodes,  :order, :overflow, :reverse, :right, :spacing, :stroke_style, :title, :top, :transform, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Layout::Pack.properties.should==props 
+  end
+  describe "rendered" do
+    before do
+    color=pv.Colors.category19
+    w=200
+    h=200
+    
+    @vis = pv.Panel.new().
+      width(w).
+      height(h).
+      top(20).
+      bottom(10).
+      left(10)
+    
+    pack = @vis.add(pv.Layout.Pack).
+    nodes(hier_nodes_big)
+    
+    pack.node.add(pv.Dot).
+    fill_style(lambda {|d| color[d.node_value]}).
+    stroke_style("black").
+    line_width(1).
+    antialias(false)
+  
+    pack.node_label.add(pv.Label).
+    text(lambda {|d| d.node_value})
+    
+    
+    @vis.render
+    
+    html_out=fixture_svg_read("layout_pack.svg")
+    @rv_svg=Nokogiri::XML(@vis.to_svg)
+    @pv_svg=Nokogiri::XML(html_out)
+    end
+    
+    it "should render equal nodes (circles)" do
+      pv_rects=@pv_svg.xpath("//circle")
+      @rv_svg.xpath("//xmlns:circle").each_with_index {|rv_rect,i|
+        rv_rect.should have_same_position pv_rects[i]
+      }
+      
+    end
+  end
+end
diff --git a/spec/layout_partition_spec.rb b/spec/layout_partition_spec.rb
new file mode 100644
index 0000000..0802240
--- /dev/null
+++ b/spec/layout_partition_spec.rb
@@ -0,0 +1,45 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Layout::Partition do
+  include Rubyvis::LayoutSpec
+  it "subclass Fill should have correct properties" do
+    props=[:antialias, :bottom, :canvas, :cursor, :data, :events, :fill_style, :height, :id, :inner_radius, :left, :line_width, :links,  :nodes,  :order, :orient, :outer_radius, :overflow, :reverse, :right, :stroke_style, :title, :top, :transform, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Layout::Partition::Fill.properties.should==props 
+  end
+  it "should be called using Rubyvis.Layout.Partition" do
+    Rubyvis.Layout.Partition.should eql Rubyvis::Layout::Partition
+  end  
+  it "should render correctly 'partition_fill' custom test" do
+    color=pv.Colors.category19
+    w=400
+    h=400
+    
+    @vis = pv.Panel.new().
+width(w).
+height(h).
+top(20).
+bottom(10).
+left(10)
+    
+    pack = @vis.add(Rubyvis::Layout::Partition::Fill).
+    nodes(hier_nodes_big).
+    orient("left").
+    size(lambda {|d|
+        d.node_value
+    })
+    
+    pack.node.add(pv.Bar).
+    fill_style(lambda {|d| color[d.node_value]}).
+    stroke_style("black").
+    line_width(1).
+    antialias(false)
+    
+    pack.node_label.add(pv.Label).
+      text(lambda {|d| d.node_name})
+    
+    
+    @vis.render
+    @pv_out=fixture_svg_read("layout_partition_fill.svg")
+    @vis.to_svg.should have_same_svg_elements(@pv_out)
+    end
+  
+end
diff --git a/spec/layout_stack_spec.rb b/spec/layout_stack_spec.rb
new file mode 100644
index 0000000..b751925
--- /dev/null
+++ b/spec/layout_stack_spec.rb
@@ -0,0 +1,128 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Layout::Stack do
+  include Rubyvis::LayoutSpec
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :canvas, :cursor, :data, :events, :fill_style, :height, :id, :layers, :left, :line_width, :offset, :order, :orient, :overflow, :reverse, :right, :stroke_style, :title, :top, :transform, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Layout::Stack.properties.should==props
+  end
+  it "Rubyvis.Dot be the same as Rubyvis::Dot" do
+    Rubyvis.Layout.Stack.should eql Rubyvis::Layout::Stack
+  end
+  describe "html examples" do 
+    before do
+      w = 300
+      @h = 300
+      
+      n = 20 # // number of layers
+      m = 75 # // number of samples per layer
+      x = pv.Scale.linear(2, m - 1).range(0, w)
+      @y = pv.Scale.linear(0, 20).range(0, @h/2.0)
+      
+      fill=pv.ramp("#ada", "#656").domain(n, 0)
+      
+      @vis = Rubyvis::Panel.new().
+        width(w).
+        height(@h)
+      
+      dat=waves(n,m)
+      @stack=@vis.add(Rubyvis::Layout::Stack).
+        layers(dat).
+        x(lambda {|d| x[self.index]}).
+        y(lambda {|d| d})
+      
+      @stack.layer.add(Rubyvis::Area).
+        fill_style(lambda {fill[self.parent.index]}).
+        stroke_style("#797")
+    end
+    
+    it "should render 'stack-expand.html' example correctly" do
+      @stack.order("inside-out").
+      offset("expand")
+      @vis.render()
+      pv_out=fixture_svg_read("stack_expand.svg")
+      @vis.to_svg.should have_same_svg_elements(pv_out)
+    end
+    it "should render 'stack-silohouette.html' example correctly" do
+      y=@y
+      @stack.order("reverse").
+      offset("silohouette").
+      y(lambda {|d| y[d]})
+    
+      @vis.render()
+      pv_out=fixture_svg_read("stack_silohouette.svg")
+      @vis.to_svg.should have_same_svg_elements(pv_out)
+    end
+    it "should render 'stack-wiggle.html' example correctly" do
+      y=@y
+      @stack.order("reverse").
+        offset("wiggle").
+      y(lambda {|d| y[d]})
+    
+      @vis.render()
+      pv_out=fixture_svg_read("stack_wiggle.svg")
+      @vis.to_svg.should have_same_svg_elements(pv_out)
+    end
+    
+  end
+  describe "rendered" do
+    before do
+      @h=200
+      @w=200
+      
+      @x=Rubyvis::Scale.linear(0,3).range(0, at w)
+      @y=Rubyvis::Scale.linear(0,10).range(0, at h)
+      
+      @vis = Rubyvis.Panel.new.width(@w).height(@h)
+      @stack=@vis.add(Rubyvis::Layout::Stack)
+    end
+    
+    describe "only with layers()" do
+      before do
+        x=@x
+        y=@y
+        @data=[[1,3,2],[2,1,3]]
+        @stack.layers(@data).
+        x(lambda {|d| x.scale(index)}).
+        y(lambda {|d| y.scale(d)}).layer.add(Rubyvis::Area)
+        @vis.render
+        doc=Nokogiri::XML(@vis.to_svg)
+        @paths=doc.xpath("//xmlns:path")
+        # <svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="200" height="200"><g><g><g><path d="M0,180L66.66666666666666,140L133.33333333333331,160L133.33333333333331,200L66.66666666666666,200L0,200Z" fill="rgb(31,119,180)"/></g><g><path d="M0,140L66.66666666666666,120L133.33333333333331,100L133.33333333333331,160L66.66666666666666,140L0,180Z" fill="rgb(174,199,232)"/></g></g></g></svg>        
+      end
+      it "should return correct number of areas" do
+        @paths.size.should eq 2
+      end
+      it "should return correct path 1" do
+        @paths[0].should have_path_data_close_to "M0 180L66.66666666666666 140L133.33333333333331 160L133.33333333333331 200L66.66666666666666 200L0 200Z"
+      end
+      it "should return correct path 2" do
+        @paths[1].should have_path_data_close_to "M0 140L66.66666666666666 120L133.33333333333331 100L133.33333333333331 160L66.66666666666666 140L0 180Z"
+      end
+    end
+    describe "using layers() and values()" do
+      before do
+        x=@x
+        y=@y
+        @data=[{:first=>1,:second=>2},{:first=>3,:second=>1},{:first=>2,:second=>3}]
+        @stack.layers([:first,:second]).
+        values(@data).
+        x(lambda {|d| x.scale(index)}).
+        y(lambda {|d,dd| y.scale(d[dd])}).layer.add(Rubyvis::Area)
+        @vis.render
+        doc=Nokogiri::XML(@vis.to_svg)
+        @paths=doc.xpath("//xmlns:path")
+        # <svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="200" height="200"><g><g><g><path d="M0,180L66.66666666666666,140L133.33333333333331,160L133.33333333333331,200L66.66666666666666,200L0,200Z" fill="rgb(31,119,180)"/></g><g><path d="M0,140L66.66666666666666,120L133.33333333333331,100L133.33333333333331,160L66.66666666666666,140L0,180Z" fill="rgb(174,199,232)"/></g></g></g></svg>       
+      end
+      it "should return correct number of areas" do
+        @paths.size.should eq 2
+      end
+      it "should return correct path 1" do
+        @paths[0].should have_path_data_close_to "M0 180L66.66666666666666 140L133.33333333333331 160L133.33333333333331 200L66.66666666666666 200L0 200Z"
+      end
+      it "should return correct path 2" do
+        @paths[1].should have_path_data_close_to "M0 140L66.66666666666666 120L133.33333333333331 100L133.33333333333331 160L66.66666666666666 140L0 180Z"
+      end
+      
+    end
+  end
+end
diff --git a/spec/layout_tree_spec.rb b/spec/layout_tree_spec.rb
new file mode 100644
index 0000000..2298470
--- /dev/null
+++ b/spec/layout_tree_spec.rb
@@ -0,0 +1,56 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Layout::Treemap do
+  include Rubyvis::LayoutSpec
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :canvas, :cursor, :data, :events, :fill_style, :height, :id, :left, :line_width, :links, :mode, :nodes, :order, :overflow, :padding_bottom, :padding_left, :padding_right, :padding_top, :reverse, :right, :round, :stroke_style, :title, :top, :transform, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Layout::Treemap.properties.should==props 
+  end
+  describe "rendered" do
+    before do
+      color=pv.Colors.category19
+      w=200
+      h=200
+      
+      @vis = pv.Panel.new().
+        width(w).
+        height(h).
+        top(20).
+        bottom(10).
+        left(10)
+      
+      @tree= @vis.add(pv.Layout.Tree).
+      nodes(hier_nodes).breadth(40)
+      
+      @tree.node.add(pv.Dot).
+      fill_style(lambda {|d| color[d.node_value]}).
+      stroke_style("black").
+      line_width(1).
+      antialias(false)
+      
+      @tree.link.add(Rubyvis::Line)
+      
+      @tree.node_label.add(Rubyvis::Label).text(lambda {|d| d.node_name})
+      
+    end
+    it "should render equal to protovis with orient 'top'" do
+      @tree.orient("top")
+      @vis.render
+      pv_out=fixture_svg_read("layout_tree_orient_top.svg")
+      @vis.to_svg.should have_same_svg_elements(pv_out)
+    end
+    
+    it  "should render correctly orient('left')" do
+      @tree.orient("left")
+      @vis.render
+      pv_out=fixture_svg_read("layout_tree_orient_left.svg")
+      @vis.to_svg.should have_same_svg_elements(pv_out)
+    end
+    
+    it "should render equal to pv with orient('radial') and breadth(20)" do
+        @tree.nodes(hier_nodes_big).orient("radial").breadth(20)
+        @vis.render
+        pv_out=fixture_svg_read("layout_tree_orient_radial_breadth_20.svg")
+        @vis.to_svg.should have_same_svg_elements(pv_out)
+    end
+  end
+end
diff --git a/spec/layout_treemap_spec.rb b/spec/layout_treemap_spec.rb
new file mode 100644
index 0000000..3eaea01
--- /dev/null
+++ b/spec/layout_treemap_spec.rb
@@ -0,0 +1,41 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Layout::Treemap do
+  include Rubyvis::LayoutSpec
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :canvas, :cursor, :data, :events, :fill_style, :height, :id, :left, :line_width, :links, :mode, :nodes, :order, :overflow, :padding_bottom, :padding_left, :padding_right, :padding_top, :reverse, :right, :round, :stroke_style, :title, :top, :transform, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Layout::Treemap.properties.should==props 
+  end
+  describe "rendered" do
+    before do
+    color=pv.Colors.category19
+    w=200
+    h=200
+
+    @vis = pv.Panel.new().
+      width(w).
+      height(h)
+    
+    treemap = @vis.add(pv.Layout.Treemap).
+    nodes(hier_nodes).
+    size(lambda {|d| d.node_value})
+    
+    treemap.leaf.add(pv.Panel).
+    fill_style(lambda {|d| color[d.node_value]}).
+    stroke_style("black").
+    line_width(1).
+    antialias(false)
+    
+    treemap.node_label.add(pv.Label).
+    text(lambda {|d| d.node_value})
+    
+      
+      @vis.render
+
+      @pv_out=fixture_svg_read("layout_treemap.svg")
+    end
+    
+    it "should render equal to protovis version " do 
+      @vis.to_svg.should have_same_svg_elements(@pv_out)
+    end
+  end
+end
diff --git a/spec/line_spec.rb b/spec/line_spec.rb
new file mode 100644
index 0000000..5eedddd
--- /dev/null
+++ b/spec/line_spec.rb
@@ -0,0 +1,189 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Line do
+  include Rubyvis::GeneralSpec
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :cursor, :data, :eccentricity, :events, :fill_style, :id, :interpolate, :left, :line_join, :line_width, :reverse, :right, :segmented, :stroke_style, :tension, :title, :top, :visible].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Line.properties.should==props
+  end
+  it "should render correctly 'line_interpolation.html' example" do
+    data = pv.range(0, 10, 0.2).map {|x|
+    OpenStruct.new({:x=>x, :y=>Math.sin(x) + 2})}
+      
+      p_w=200
+      p_h=150
+      w = 20+p_w*2
+      h = 20+p_h*4
+      
+      p_w=200
+      p_h=150
+      #p data
+      w = 20+p_w*2
+      h = 20+p_h*4
+      
+      x = pv.Scale.linear(data, lambda {|d| d.x}).range(0, p_w-30)
+      
+      
+      y = pv.Scale.linear(data, lambda {|d| d.y}).range(0, p_h-20);
+      
+      interpolations=["linear","step-before","step-after","polar","polar-reverse", "basis", "cardinal"]
+      
+      #/* The root panel. */
+      vis = pv.Panel.new().
+width(w).
+height(h).
+bottom(20).
+left(20).
+right(10).
+top(5)
+      
+      interpolations.each_with_index do |inter,i|
+      n=i%2
+      m=(i/2).floor
+      panel=vis.add(Rubyvis::Panel).
+      left(n*(p_w+10)).
+      top(m*(p_h+10)).
+      width(p_w).
+      height(p_h)
+      panel.anchor('top').add(Rubyvis::Label).text(inter)
+      panel.add(Rubyvis::Line).data(data).
+      line_width(2).
+      left(lambda {|d| x.scale(d.x)}).
+      bottom(lambda {|d| y.scale(d.y)}).
+      interpolate(inter)
+  
+    end
+    vis.render()
+    pv_out=fixture_svg_read("line_interpolation.svg")
+    vis.to_svg.should have_same_svg_elements(pv_out)
+  end
+  it "should render correctly 'line_interpolation_segmented.html' example" do
+    data = pv.range(0, 10, 0.2).map {|x|
+    OpenStruct.new({:x=>x, :y=>Math.sin(x) + 2})}
+      
+      p_w=200
+      p_h=150
+      w = 20+p_w*2
+      h = 20+p_h*4
+      
+      p_w=200
+      p_h=150
+      #p data
+      w = 20+p_w*2
+      h = 20+p_h*4
+      
+      x = pv.Scale.linear(data, lambda {|d| d.x}).range(0, p_w-30)
+      
+      
+      y = pv.Scale.linear(data, lambda {|d| d.y}).range(0, p_h-20);
+      
+      interpolations=["linear","step-before","step-after","polar","polar-reverse", "basis", "cardinal","monotone"]
+      #/* The root panel. */
+      vis = pv.Panel.new().
+width(w).
+height(h).
+bottom(20).
+left(20).
+right(10).
+top(5)
+      
+      interpolations.each_with_index do |inter,i|
+      n=i%2
+      m=(i/2).floor
+      panel=vis.add(Rubyvis::Panel).
+      left(n*(p_w+10)).
+      top(m*(p_h+10)).
+      width(p_w).
+      height(p_h)
+    
+      panel.anchor('top').add(Rubyvis::Label).text(inter)
+      
+      panel.add(Rubyvis::Line).data(data).
+      segmented(true).
+      line_width(lambda {|d|d.y*2.0+self.index*0.5}).
+      left(lambda {|d| x.scale(d.x)}).
+      bottom(lambda {|d| y.scale(d.y)}).
+      interpolate(inter)
+    end
+    vis.render()
+    pv_out=fixture_svg_read("line_interpolation_segmented.svg")
+    vis.to_svg.should have_same_svg_elements(pv_out)
+  end
+  it "SvgScene.path_join should return correct value" do
+    s0=OpenStruct.new({:left=>1,:top=>2,:visible=>true, :line_width=>2.5})
+    s1=OpenStruct.new({:left=>3,:top=>4,:visible=>true, :line_width=>2.5})
+    s2=OpenStruct.new({:left=>5,:top=>6,:visible=>true, :line_width=>2.5})
+    s3=OpenStruct.new({:left=>7,:top=>8,:visible=>true, :line_width=>2.5})
+    # obj.attributes["d"].value
+    exp_data="M2.1161165235168156,4.883883476483184L4.116116523516816,6.883883476483184 5.883883476483184,5.116116523516816 3.8838834764831844,3.1161165235168156"
+    obs=""
+    obs.stub!(:attributes).and_return({'d'=>OpenStruct.new({:value=>Rubyvis::SvgScene.path_join(s0,s1,s2,s3)})})
+    
+    obs.should have_path_data_close_to exp_data
+    
+    s0=OpenStruct.new({:left=>1.5,:top=>2,:visible=>true, :line_width=>3})
+    s1=OpenStruct.new({:left=>3.5,:top=>4,:visible=>true, :line_width=>3.5})
+    s2=OpenStruct.new({:left=>5.5,:top=>6,:visible=>true, :line_width=>4.0})
+    s3=OpenStruct.new({:left=>7.5,:top=>8,:visible=>true, :line_width=>4.5})
+    exp_data="M2.2625631329235425,5.2374368670764575L4.2625631329235425,7.2374368670764575 6.7374368670764575,4.7625631329235425 4.7374368670764575,2.7625631329235425"
+    obs=""
+    obs.stub!(:attributes).and_return({'d'=>OpenStruct.new({:value=>Rubyvis::SvgScene.path_join(s0,s1,s2,s3)})})
+    obs.should have_path_data_close_to exp_data
+  
+  end
+  context "rendered" do
+    before do
+      @h=200
+      @w=200
+      @vis = Rubyvis.Panel.new.width(@w).height(@h)
+      @area=@vis.add(pv.Line).
+        data([1,2,1,4,1,5]).
+        bottom(lambda {|d| d*20}).
+        left(lambda {index*20})
+    end
+    it "should return correct default (linear) path" do
+      @vis.render
+      doc=Nokogiri::XML(@vis.to_svg)
+      doc.at_xpath("//xmlns:path").should have_path_data_close_to  "M0 180L20 160L40 180L60 120L80 180L100 100L100 200L80 200L60 200L40 200L20 200L0 200Z"
+    end
+    it "should return correct path for interpolate=step-before" do
+      @area.interpolate('step-before')
+      @vis.render
+      doc=Nokogiri::XML(@vis.to_svg)
+      doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0,180V160H20V180H40V120H60V180H80V100H100"
+    end
+    it "should return correct path for interpolate=step-after" do
+      @area.interpolate('step-after')
+      @vis.render
+      doc=Nokogiri::XML(@vis.to_svg)
+      doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0,180H20V160H40V180H60V120H80V180H100V100"
+    end
+    
+    it "should return correct path for interpolate=polar" do
+      @area.interpolate('polar')
+      @vis.render
+      doc=Nokogiri::XML(@vis.to_svg)
+      doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0,180A14.142135623730951,14.142135623730951 0 0,1 20,160A14.142135623730951,14.142135623730951 0 0,1 40,180A31.622776601683793,31.622776601683793 0 0,1 60,120A31.622776601683793,31.622776601683793 0 0,1 80,180A41.23105625617661,41.23105625617661 0 0,1 100,100"
+    end
+    
+    
+    it "should return correct path for interpolate=polar-reverse" do
+     
+      @area.interpolate('polar-reverse')
+      @vis.render
+      doc=Nokogiri::XML(@vis.to_svg)
+      doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0,180A14.142135623730951,14.142135623730951 0 0,0 20,160A14.142135623730951,14.142135623730951 0 0,0 40,180A31.622776601683793,31.622776601683793 0 0,0 60,120A31.622776601683793,31.622776601683793 0 0,0 80,180A41.23105625617661,41.23105625617661 0 0,0 100,100"
+    end
+    it "should return correct path for interpolate=basis" do
+      @area.interpolate('basis')
+      @vis.render
+      doc=Nokogiri::XML(@vis.to_svg)
+      doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0 180C0 180 0 180 3.333333333333333 176.66666666666666C6.666666666666666 173.33333333333331 13.333333333333332 166.66666666666666 20 166.66666666666666C26.666666666666664 166.66666666666666 33.33333333333333 173.33333333333331 40 166.66666666666666C46.666666666666664 160 53.33333333333333 140 60 140C66.66666666666666 140 73.33333333333333 160 80 156.66666666666666C86.66666666666666 153.33333333333331 93.33333333333331 12 [...]
+    end   
+    it "should return correct path for interpolate=cardinal" do 
+      @area.interpolate('cardinal')
+      @vis.render
+      doc=Nokogiri::XML(@vis.to_svg)
+      doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0 180Q16 160 20 160C26 160 34 186 40 180S54 120 60 120S74 183 80 180Q84 178 100 100"
+    end
+  end
+end
diff --git a/spec/mark_spec.rb b/spec/mark_spec.rb
new file mode 100644
index 0000000..617c9d2
--- /dev/null
+++ b/spec/mark_spec.rb
@@ -0,0 +1,20 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Mark do
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :cursor, :data, :events, :id, :left, :reverse, :right, :title, :top, :visible].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Mark.properties.should==props
+  end
+  it "should return correct defaults" do
+    props=Rubyvis::Mark.defaults._properties.sort {|a,b| a.name.to_s<=>b.name.to_s}
+    props[1].name.should==:data
+    props[1].value.should be_instance_of Proc
+    props[3].name.should==:visible
+    props[0].name.should==:antialias
+    props[2].name.should==:events
+  end
+  it "should have 'mark' as type" do
+    m=Rubyvis::Mark.new
+    m.type.should eql "mark"
+  end
+  
+end
\ No newline at end of file
diff --git a/spec/nest_spec.rb b/spec/nest_spec.rb
new file mode 100644
index 0000000..720ea3d
--- /dev/null
+++ b/spec/nest_spec.rb
@@ -0,0 +1,47 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Nest do
+  before do
+    @data=[
+    { :year=>2010, :city=>'London',:value=>1},
+    { :year=>2010, :city=>'France',:value=>2},
+    { :year=>2011, :city=>'London',:value=>5},
+    { :year=>2011, :city=>'France',:value=>6},
+  ]
+  end
+  it "should generate correct map" do
+    nest = pv.nest(@data).key(lambda {|d| d[:year]}).key(lambda {|d|  d[:city]}).map()
+    
+    expected={2010=>{"London"=>[{:year=>2010, :city=>"London", :value=>1}], "France"=>[{:year=>2010, :city=>"France", :value=>2}]}, 2011=>{"London"=>[{:year=>2011, :city=>"London", :value=>5}], "France"=>[{:year=>2011, :city=>"France", :value=>6}]}}
+    nest.should==expected
+
+  end
+  it "should generate correct rollup" do
+    nest = pv.nest(@data).key(lambda {|d| d[:year]}).key(lambda {|d|  d[:city]}).rollup(lambda {|d| d.map{|dd| dd[:value]}})
+    expected={2010=>{"London"=>[1], "France"=>[2]}, 2011=>{"London"=>[5], "France"=>[6]}}
+    nest.should==expected
+    
+  end
+  it "should generate correct entries" do
+    nest = pv.nest(@data).key(lambda {|d| d[:year]}).key(lambda {|d|  d[:city]}).entries();
+    expected=[
+    Rubyvis::NestedArray.new(:key=>2010, :values=>
+      [
+        Rubyvis::NestedArray.new(:key=>'London', :values=>
+          [{:year=>2010, :city=>'London',:value=>1}]),
+        Rubyvis::NestedArray.new(:key=>'France', :values=>
+          [{:year=>2010, :city=>'France',:value=>2}])
+      ]),
+    Rubyvis::NestedArray.new(:key=>2011, :values=>
+      [
+        Rubyvis::NestedArray.new(:key=>'London', :values=>
+          [{:year=>2011, :city=>'London',:value=>5}]),
+        Rubyvis::NestedArray.new(:key=>'France', :values=>
+          [{:year=>2011, :city=>'France',:value=>6}])
+      ])
+    ]
+    
+    nest.should==expected
+      
+  end
+  
+end
\ No newline at end of file
diff --git a/spec/panel_spec.rb b/spec/panel_spec.rb
new file mode 100644
index 0000000..13adcff
--- /dev/null
+++ b/spec/panel_spec.rb
@@ -0,0 +1,35 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Panel do
+  before do
+    @h=200
+    @w=200
+    @vis = Rubyvis.Panel.new.width(@w).height(@h)
+  end
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :canvas, :cursor, :data, :events, :fill_style, :height, :id, :left, :line_width, :overflow, :reverse, :right, :stroke_style, :title, :top, :transform, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Panel.properties.should==props
+  end
+  it "should have correct defaults" do
+    Rubyvis::Panel.defaults._properties.size.should==2
+  end
+  it "should build propertly" do
+    lambda {@vis.render}.should_not raise_exception
+  end
+  it "should return valid svg" do   
+    @vis.render
+    doc=Nokogiri::XML(@vis.to_svg)
+    doc.at_xpath("//xmlns:svg").should have_svg_attributes({"font-size"=>"10px", "font-family"=>"sans-serif", "fill"=>"none", "stroke"=>"none", "stroke-width"=>"1.5", "width"=>"200.0", "height"=>"200.0"})
+  end
+  it "should allow multiple panel definitions" do
+    vis2 = Rubyvis.Panel.new.width(@w+100).height(@h+100)
+    @vis.render
+    vis2.render
+    doc1=Nokogiri::XML(@vis.to_svg)
+    doc2=Nokogiri::XML(vis2.to_svg)
+
+    doc1.at_xpath("//xmlns:svg").should have_svg_attributes({"font-size"=>"10px", "font-family"=>"sans-serif", "fill"=>"none", "stroke"=>"none", "stroke-width"=>"1.5", "width"=>"200.0", "height"=>"200.0"})
+    
+    doc2.at_xpath("//xmlns:svg").should have_svg_attributes({"font-size"=>"10px", "font-family"=>"sans-serif", "fill"=>"none", "stroke"=>"none", "stroke-width"=>"1.5", "width"=>"300.0", "height"=>"300.0"})
+    
+  end
+end
\ No newline at end of file
diff --git a/spec/readme_spec.rb b/spec/readme_spec.rb
new file mode 100644
index 0000000..f82d159
--- /dev/null
+++ b/spec/readme_spec.rb
@@ -0,0 +1,38 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe "Rubyvis Readme" do
+  it "should work with RBP API" do
+    vis=nil
+    lambda {
+    vis = Rubyvis::Panel.new do 
+      width 150
+      height 150
+      bar do
+        data [1, 1.2, 1.7, 1.5, 0.7, 0.3]
+        width 20
+        height {|d| d * 80}
+        bottom(0)
+        left {index * 25}
+      end
+    end
+    
+    vis.render}.should_not raise_exception
+    vis.to_svg.size.should>0
+  end
+  it "should work with Protovis API" do
+    vis=nil
+    lambda {
+    vis = Rubyvis::Panel.new.width(150).height(150);
+    
+    vis.add(pv.Bar).
+      data([1, 1.2, 1.7, 1.5, 0.7, 0.3]).
+      width(20).
+      height(lambda {|d| d * 80}).
+      bottom(0).
+      left(lambda {self.index * 25});
+    
+    vis.render
+    }.should_not raise_exception
+    vis.to_svg.size.should>0
+  end
+  
+end
diff --git a/spec/ruby_api_spec.rb b/spec/ruby_api_spec.rb
new file mode 100644
index 0000000..89edd85
--- /dev/null
+++ b/spec/ruby_api_spec.rb
@@ -0,0 +1,70 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+shared_examples_for "Ruby API for Rubyvis" do
+  before do
+    @h=200
+    @w=200
+  end
+  it "should create a Panel with a block" do
+    lambda {@vis = Rubyvis.Panel.new {
+      width @w
+      height @h
+    }
+    }.should_not raise_exception
+    @vis._properties.size.should==2
+  end
+  it "should create a Bar with new method" do
+    vis1=Rubyvis.Panel.new.width(@w).height(@h)
+    vis1.add(Rubyvis::Bar).
+      data([1,2,3]).
+      width(10).
+      height(10).
+      left(lambda {|x| x*10}).anchor('top').
+        add(Rubyvis::Label).
+          text(lambda {|x| x})
+    vis1.render
+    svg1=vis1.to_svg
+  
+    ww=@w
+    hh=@h
+    vis2=Rubyvis.Panel.new {|pan|
+      pan.width ww
+      pan.height hh
+      pan.bar {
+        data([1,2,3])
+        width 10
+        height 10
+        left {|x| x*10}
+        label(:anchor=>'top') {
+          text {|x| x}
+        }
+      }
+    }
+    vis2.render
+    svg2=vis2.to_svg
+    svg1.should==svg2
+    
+  end
+end
+
+describe "Rubyvis with REXML" do
+  before(:all) do
+    $rubyvis_no_nokogiri=true
+  end
+  after(:all) do
+    $rubyvis_no_nokogiri=false    
+  end
+  it_should_behave_like "Ruby API for Rubyvis"
+end
+
+if Rubyvis.has_nokogiri? 
+  describe "Rubyvis with Nokogiri" do
+
+    before(:all) do
+      $rubyvis_no_nokogiri=false
+    end
+    
+    it_should_behave_like "Ruby API for Rubyvis"
+
+    
+  end
+end
diff --git a/spec/rule_spec.rb b/spec/rule_spec.rb
new file mode 100644
index 0000000..683b20f
--- /dev/null
+++ b/spec/rule_spec.rb
@@ -0,0 +1,33 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Rule do
+  include Rubyvis::GeneralSpec
+  it "should have correct properties" do
+    props=[:antialias, :bottom, :cursor, :data, :events, :height,  :id, :left, :line_width, :reverse, :right, :stroke_style, :title, :top, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Rule.properties.should==props
+  end
+  it "Rubyvis.Rule be the same as Rubyvis::Rule" do
+    Rubyvis.Rule.should eql Rubyvis::Rule
+  end
+  it "should render equal to protovis 'rule-anchor.html' test" do
+    vis = Rubyvis::Panel.new().
+      width(400).
+      height(300)
+    
+    
+    bar=vis.add(pv.Bar).
+      data(["left", "top", "right", "bottom", "center"]).
+      width(300).
+      height(30).
+      left(40).
+      right(40).
+      top(lambda {self.index*60}).fill_style('red')
+    
+    rule = bar.add(pv.Rule)
+    rule.anchor(lambda {|d| d}).add(pv.Label).text(lambda {|d| d})
+    
+    vis.render();
+    pv_out=fixture_svg_read("rule_anchor.svg")
+    vis.to_svg.should have_same_svg_elements(pv_out)
+  end  
+  
+end
\ No newline at end of file
diff --git a/spec/scale_linear_datetime_spec.rb b/spec/scale_linear_datetime_spec.rb
new file mode 100644
index 0000000..0fab78b
--- /dev/null
+++ b/spec/scale_linear_datetime_spec.rb
@@ -0,0 +1,56 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe "Rubyvis::Scale::Linear with dates" do
+  it "should be created as Javascript" do
+    h=280
+    y = Rubyvis.Scale.linear(Time.utc(2010,1,1), Time.utc(2010,2,1))
+  end
+  
+  before do
+    @bd=Time.utc(2010,1,1)
+    @ed=Time.utc(2010,2,1)
+    @h=280
+    @y = Rubyvis.Scale.linear(@bd, @ed).range(0, at h)
+  end
+  it "y should be a Scale" do
+    @y.should be_a(Rubyvis::Scale::Linear)
+  end
+  it "should respond to domain" do
+    @y.domain.should==[@bd, @ed]
+    @y.domain(@bd)
+    @y.domain.should==[@bd, at bd]
+    @y.domain(@bd, at ed, at ed+1)
+    @y.domain.should==[@bd, at ed, at ed+1]
+  end
+  it "should respond to range" do
+    @y.range.should==[0, @h]
+    @y.range(1)
+    @y.range.should==[1,1]
+    @y.range(1,100,300)
+    @y.range.should==[1,100,300]
+  end
+  it "should returns correct scale" do
+    @y.scale(@bd).should==0
+    @y.scale(@ed).should==@h
+    @y[@ed].should==@h
+    val= (@ed.to_f+ at bd.to_f) / 2.0
+    @y.scale(val).should be_within( 0.001).of(@h / 2.0)
+  end
+  it "should returns correct invert" do
+    @y.invert(0).should==@bd
+    @y.invert(@h).should==@ed
+  end
+  it "should returns correct ticks" do
+    @y.ticks.size.should==5
+    @y.ticks(5).size.should==5
+    @y.ticks(5)[0].should be_instance_of Time
+    
+    #p @y.ticks
+  end
+  it "should returns correct tick_format" do
+    pending()
+  end
+
+  it "should nice nicely" do
+    pending()
+  end
+end
\ No newline at end of file
diff --git a/spec/scale_linear_spec.rb b/spec/scale_linear_spec.rb
new file mode 100644
index 0000000..ee90c41
--- /dev/null
+++ b/spec/scale_linear_spec.rb
@@ -0,0 +1,140 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Scale::Linear do
+  if Rubyvis::JohnsonLoader.available?
+    context "direct protovis API comparison" do 
+      before(:all) do
+        @rt=  Rubyvis::JohnsonLoader.new().runtime
+      end
+      before do 
+        @h=280
+        @h_dom=1000
+        @y = Rubyvis.Scale.linear(0, @h_dom).range(0, at h)
+        @rt[:h_dom] = @h_dom
+        @rt[:h] = @h
+        @y_js=@rt.evaluate("y=pv.Scale.linear(0, h_dom).range(0,h)")
+        @v1, at v2, at v3=rand(),rand()+3,rand()+5
+        @rt[:v1]=@v1
+        @rt[:v2]=@v2
+        @rt[:v3]=@v3
+
+      end
+      it "domain() implemented equally" do
+        @y.domain(@v1)
+        @rt.evaluate("y.domain(v1)")
+        @y.domain.should==@rt.evaluate("y.domain()").to_a
+        @y.domain(@v1, at v2, at v3)
+        @rt.evaluate("y.domain(v1,v2,v3)")
+        @y.domain.should==@rt.evaluate("y.domain()").to_a        
+      end
+      it "scale() implemented equally for complex domain" do
+        @y.domain(@v1, at v2, at v3)
+        @rt.evaluate("y.domain(v1,v2,v3)")
+        @y.scale(@v1+1).should==@rt.evaluate("y(v1+1)")
+        @y.scale(@v2+1).should==@rt.evaluate("y(v2+1)")
+        @y.scale(@v3+1).should==@rt.evaluate("y(v3+1)")
+      end
+      it "invert() implemented equally" do
+        @y.domain(@v1, at v2, at v3)
+        @rt.evaluate("y.domain(v1,v2,v3)")
+        @y.invert(@v1+1).should==@rt.evaluate("y.invert(v1+1)")
+        @y.invert(@v2+1).should==@rt.evaluate("y.invert(v2+1)")
+        @y.invert(@v3+1).should==@rt.evaluate("y.invert(v3+1)")
+      end
+      it "ticks() implemented equally for numbers" do
+        @y.ticks.should==@rt.evaluate("y.ticks()").to_a
+        (5..20).each {|i|
+          @rt[:i]=i
+          @y.ticks(i).should==@rt.evaluate("y.ticks(i)").to_a
+        }
+      end
+      it "nice() implemented equally" do
+        @y.domain(@v1, at v2)
+        @rt.evaluate("y.domain(v1,v2)")
+        @y.nice
+        @rt.evaluate("y.nice()")
+        @y.domain.should==@rt.evaluate("y.domain()").to_a
+      end
+   
+    end
+    
+  end
+  it "should be created as Javascript" do
+    h=280
+    y = Rubyvis.Scale.linear(0, 1500)
+  end
+  
+  before do
+    @h=280
+    @h_dom=1000
+    @y = Rubyvis.Scale.linear(0, @h_dom).range(0, at h)
+  end
+  it "y should be a Scale" do
+    @y.should be_a(Rubyvis::Scale::Linear)
+  end
+  it "should respond to domain" do
+    @y.domain.should==[0, 1000]
+    @y.domain(1)
+    @y.domain.should==[1,1]
+    @y.domain(1,100,300)
+    @y.domain.should==[1,100,300]
+  end
+  it "should respond to range" do
+    @y.range.should==[0, 280]
+    @y.range(1)
+    @y.range.should==[1,1]
+    @y.range(1,100,300)
+    @y.range.should==[1,100,300]
+  end
+  it "should returns correct scale" do
+    @y.scale(@h_dom).should==280
+    @y[@h_dom].should==280
+    val=20
+    @y.scale(val).should be_within( 0.001).of(val.quo(@h_dom)*@h.to_f)
+  end
+  it "should return correct scale when values are extracted from data " do
+    data = pv.range(0, 10, 0.1).map {|x| OpenStruct.new({:x=> x, :y=> Math.sin(x) + 2+rand()}) }
+    w = 400
+    h = 200
+    x = pv.Scale.linear(data, lambda {|d| d.x}).range(0, w)
+    y = pv.Scale.linear(data, lambda {|d| d.y}).range(0, h)
+    lambda {y.scale 0.5}.should_not raise_error
+  end
+  it "should returns correct invert" do
+    @y.invert(100).should be_within( 0.001).of(357.1428)
+    @y.invert(200).should be_within( 0.001).of(714.2857)
+  end
+  it "should returns correct ticks" do
+    @y.ticks.should==[0,100,200,300,400,500,600,700,800,900,1000]
+    @y.ticks(13).should==[0,100,200,300,400,500,600,700,800,900,1000]
+    @y.ticks(5).should==[0,200,400,600,800,1000]
+  end
+  it "should return correct tick when domain is a scalar" do
+    @y.domain(1,1,1).ticks.should==[1]
+  end
+
+  it "should nice nicely" do
+    @y.domain([0.20147987687960267, 0.996679553296417])
+    @y.nice
+    @y.domain().should==[0.2,1]
+  end
+  
+  it "should returns correct tick_format" do
+    @y.tick_format.should be_instance_of Proc
+    @y.tick_format.call( 2).should=='2'
+    @y.tick_format.call(2.0).should=='2'
+    @y.tick_format.call(2.1).should=='2.1'
+    @y.tick_format.call("a").should==''
+  end
+  it "should return correct tick_format for small numbers" do
+    @y.domain(0.00001,0.0001)
+    @y.range(0.000001,0.0001)
+    @y.ticks.should==[1.quo(100000), 1.quo(50000), 3.quo(100000), 1.quo(25000), 1.quo(20000), 3.quo(50000), 7.quo(100000), 1.quo(12500), 9.quo(100000), 1.quo(10000)]
+    @y.tick_format.call(0.2).should=='0.20000'
+  end
+  it "should return correct by" do
+    by=@y.by(lambda {|v| v.value})
+    a=OpenStruct.new({:value=>rand})
+    by.call(a).should==@y[a.value]
+  end
+  
+end
\ No newline at end of file
diff --git a/spec/scale_log_spec.rb b/spec/scale_log_spec.rb
new file mode 100644
index 0000000..132f1fd
--- /dev/null
+++ b/spec/scale_log_spec.rb
@@ -0,0 +1,114 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Scale::Log do
+  if Rubyvis::JohnsonLoader.available?
+    context "direct protovis API comparison" do 
+      before(:all) do
+        @rt=  Rubyvis::JohnsonLoader.new("/data/LogScale.js").runtime
+      end
+      before do 
+        @h=280
+        @h_dom=1000
+        @y = Rubyvis.Scale.log(1, @h_dom).range(1, at h)
+        @rt[:h_dom] = @h_dom
+        @rt[:h] = @h
+        @y_js=@rt.evaluate("y=pv.Scale.log(1, h_dom).range(1,h)")
+        @v1, at v2, at v3=rand()+1,rand()+3,rand()+5
+        @rt[:v1]=@v1
+        @rt[:v2]=@v2
+        @rt[:v3]=@v3
+
+      end
+      it "domain() implemented equally" do
+        @y.domain(@v1)
+        @rt.evaluate("y.domain(v1)")
+        @y.domain.should==@rt.evaluate("y.domain()").to_a
+        @y.domain(@v1, at v2, at v3)
+        @rt.evaluate("y.domain(v1,v2,v3)")
+        @y.domain.should==@rt.evaluate("y.domain()").to_a        
+      end
+      it "scale() implemented equally for complex domain" do
+        @y.domain(@v1, at v2, at v3)
+        @rt.evaluate("y.domain(v1,v2,v3)")
+        @y.scale(@v1+1).should==@rt.evaluate("y(v1+1)")
+        @y.scale(@v2+1).should==@rt.evaluate("y(v2+1)")
+        @y.scale(@v3+1).should==@rt.evaluate("y(v3+1)")
+      end
+      it "invert() implemented equally" do
+        @y.domain(@v1, at v2, at v3)
+        @rt.evaluate("y.domain(v1,v2,v3)")
+        @y.invert(@v1+1).should==@rt.evaluate("y.invert(v1+1)")
+        @y.invert(@v2+1).should==@rt.evaluate("y.invert(v2+1)")
+        @y.invert(@v3+1).should==@rt.evaluate("y.invert(v3+1)")
+      end
+      it "ticks() implemented equally for numbers" do
+        @y.ticks.should==@rt.evaluate("y.ticks()").to_a
+        
+      end
+      it "nice() implemented equally" do
+        @y.domain(@v1, at v2)
+        @rt.evaluate("y.domain(v1,v2)")
+        @y.nice
+        @rt.evaluate("y.nice()")
+        @y.domain.should==@rt.evaluate("y.domain()").to_a
+      end
+   
+    end
+    
+  end
+  it "should be created as Javascript" do
+    h=280
+    y = Rubyvis.Scale.log(1, 1500)
+  end
+  
+  before do
+    @h=280
+    @h_dom=1000
+    @y = Rubyvis.Scale.log(1, @h_dom).range(1, at h)
+  end
+  it "y should be a Scale" do
+    @y.should be_a(Rubyvis::Scale::Log)
+  end
+  it "should respond to domain" do
+    @y.domain.should==[1, 1000]
+    @y.domain(1)
+    @y.domain.should==[1,1]
+    @y.domain(1,100,300)
+    @y.domain.should==[1,100,300]
+  end
+  it "should respond to range" do
+    @y.range.should==[1, 280]
+    @y.range(1)
+    @y.range.should==[1,1]
+    @y.range(1,100,300)
+    @y.range.should==[1,100,300]
+  end
+  it "should returns correct scale" do
+    @y.scale(@h_dom).should==280
+    @y[@h_dom].should==280
+    val=20
+    @y.scale(val).should be_within( 0.001).of(121.995)
+  end
+  it "should returns correct invert" do
+    @y.invert(100).should be_within( 0.001).of(11.601)
+    @y.invert(200).should be_within( 0.001).of(137.970)
+  end
+  it "should returns correct ticks" do
+    t=1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100,200,300,400,500,600,700,800,900,1000
+    @y.ticks.should==t
+  end
+  it "should returns correct ticks with subdivisions" do
+    t=1,5,10,50,100,500,1000
+    @y.ticks(2).should==t
+    t=1,2.5,5,7.5,10,25,50,75,100,250,500,750,1000
+    @y.ticks(4).should==t
+    t=1,2,4,6,8,10,20,40,60,80,100,200,400,600,800,1000
+    @y.ticks(5).should==t
+    t=1,10,100,1000
+    @y.ticks(1).should==t
+  end
+  it "should nice nicely" do
+    @y.domain([0.20147987687960267, 0.996679553296417])
+    @y.nice
+    @y.domain().should==[0.1,1]
+  end  
+end
\ No newline at end of file
diff --git a/spec/scale_ordinal_spec.rb b/spec/scale_ordinal_spec.rb
new file mode 100644
index 0000000..e3c0ab9
--- /dev/null
+++ b/spec/scale_ordinal_spec.rb
@@ -0,0 +1,85 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Scale::Ordinal do
+  if Rubyvis::JohnsonLoader.available?
+    context "direct protovis API comparison" do 
+      before(:all) do
+        @rt=  Rubyvis::JohnsonLoader.new("/data/OrdinalScale.js").runtime
+      end
+      before do 
+        @base  = %w{a b c d e f}
+        @range = %w{black red white orange yellow blue}
+        @n=rand(3)+3
+        @base=@base[0, at n]
+        @range=@range[0, at n]        
+        @y = Rubyvis.Scale.ordinal(@base).range(@range)
+        @rt[:domain] = @base
+        @rt[:range] = @range
+        @y_js=@rt.evaluate("y=pv.Scale.ordinal(domain).range(range)")
+
+      end
+      
+      it "domain() implemented equally" do
+        @y.domain(@base[0])
+        @rt.evaluate("y.domain(domain[0])")
+        @y.domain.should==@rt.evaluate("y.domain()").to_a
+        @y.domain(@base[0], at base[1])
+        @rt.evaluate("y.domain(domain[0],domain[1])")
+        @y.domain.should==@rt.evaluate("y.domain()").to_a        
+      end
+      
+    end
+  end
+  describe "on ruby domain" do 
+    it "should be created as Javascript" do
+      lambda {y = Rubyvis.Scale.ordinal(%w{a b c}).range(%w{red blue black})}.should_not raise_exception
+    end
+    
+    before do
+      @domain=%w{a b c}
+      @range=%w{red white blue}
+      @y = Rubyvis.Scale.ordinal(@domain).range(@range)
+    end
+    it "y should be a Scale::Ordinal" do
+      @y.should be_a(Rubyvis::Scale::Ordinal)
+    end
+    it "should respond to domain" do
+      @y.domain.should==%w{a b c}
+      @y.domain(%w{a})
+      @y.domain.should==%w{a}
+      @y.domain(1,100,300)
+      @y.domain.should==[1,100,300]
+    end
+    it "should respond to range" do
+      @y.range.should==@range.map {|c| pv.color(c)}
+      @y.range('red')
+      @y.range.should==[pv.color('red')]
+      @y.range('black','white')
+      @y.range.should==[pv.color('black'), pv.color('white')]
+    end
+    it "should returns correct scale with unknown values" do
+      @y.scale(1).should==pv.color('red')
+      @y.scale('x').should==pv.color('white')
+      @y.scale(9).should==pv.color('blue')
+      @y.scale(1).should==pv.color('red')      
+    end
+    it "should return the same using [] and scale()" do
+      a=rand()
+      @y[a].should==@y.scale(a)
+    end
+    it "should returns correct scale with known values" do
+      @y.scale('a').should==pv.color('red')
+      @y.scale('b').should==pv.color('white')
+      @y.scale('c').should==pv.color('blue')
+    end
+    it "should return correct by" do
+      @y = Rubyvis.Scale.ordinal(@domain).range(@range).by(lambda {|v| v.nombre})
+      a=OpenStruct.new({:nombre=>'c'})
+      b=OpenStruct.new({:nombre=>'b'})
+      c=OpenStruct.new({:nombre=>'a'})
+      @y.call(a).should==pv.color('blue')
+      @y.call(b).should==pv.color('white')
+      @y.call(c).should==pv.color('red')
+      
+    end
+  end
+end
\ No newline at end of file
diff --git a/spec/scale_spec.rb b/spec/scale_spec.rb
new file mode 100644
index 0000000..8cff772
--- /dev/null
+++ b/spec/scale_spec.rb
@@ -0,0 +1,8 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Scale do
+  it "should return a correct numeric interpolator" do
+    i=Rubyvis::Scale.interpolator(0,20)
+    i[10].should==200
+    i[20].should==400
+  end
+end
\ No newline at end of file
diff --git a/spec/spec.opts b/spec/spec.opts
new file mode 100644
index 0000000..d8ed776
--- /dev/null
+++ b/spec/spec.opts
@@ -0,0 +1,3 @@
+--color
+-f s
+-b
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 0000000..e46cd5d
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,249 @@
+$:.unshift(File.dirname(__FILE__)+"/../lib")
+begin
+  require 'simplecov'
+  SimpleCov.start do
+    add_filter "/spec/"
+    add_group "Libraries", "lib"
+  end
+rescue LoadError
+end
+require 'rspec'
+#require 'spec/autorun'
+require 'rubyvis'
+require 'pp'
+require 'nokogiri'
+
+
+$PROTOVIS_DIR=File.dirname(__FILE__)+"/../vendor/protovis/src"
+module Rubyvis
+  module GeneralSpec
+    def fixture_svg_read(filename)
+      File.read(File.dirname(__FILE__)+"/fixtures/#{filename}")
+    end
+  end
+  module LayoutSpec
+    include GeneralSpec
+    def waves(n, m) 
+    Rubyvis.range(n).map {|i| 
+      Rubyvis.range(m).map {|j| 
+        x = 20 * j / m.to_f - i / 3.0
+        x > 0 ? 2 * x * Math.exp(-0.5 * x) : 0
+      }
+    }
+    end
+
+    
+    
+    
+    def net_nodes
+      [
+      OpenStruct.new({:node_value=>'A', :group=>1}),
+      OpenStruct.new({:node_value=>'B', :group=>1}),
+      OpenStruct.new({:node_value=>'C', :group=>2}),
+      OpenStruct.new({:node_value=>'D',:group=>2}),
+      OpenStruct.new({:node_value=>'E',:group=>3}),
+      OpenStruct.new({:node_value=>'F',:group=>3})
+      
+      ]
+    end
+    def net_links
+      [
+      OpenStruct.new({:source=>0,:target=>1, :value=>1}),
+      OpenStruct.new({:source=>1,:target=>2, :value=>1}),
+      OpenStruct.new({:source=>2,:target=>3, :value=>1}),
+      OpenStruct.new({:source=>3,:target=>4, :value=>1}),
+      OpenStruct.new({:source=>4,:target=>5, :value=>1}),
+      OpenStruct.new({:source=>1,:target=>0, :value=>1}),
+      OpenStruct.new({:source=>2,:target=>1, :value=>1}),
+      OpenStruct.new({:source=>3,:target=>2, :value=>1}),
+      OpenStruct.new({:source=>4,:target=>3, :value=>1}),
+      OpenStruct.new({:source=>5,:target=>4, :value=>1}),
+      ]
+    end
+    def hier_nodes
+      Rubyvis.dom({:a=>1,:b=>{:ba=>2,:bb=>{:bba=>3}, :bc=>4}, :c=>5}).root("test").nodes
+    end
+    def hier_nodes_big
+      subtree={:a=>1,:b=>2,:c=>3,:d=>4}
+
+      Rubyvis.dom({:a=>subtree,:b=>subtree, :c=>subtree, :d=>subtree,:e=>subtree,:f=>subtree}).root("test").nodes()
+
+    end
+  end
+  class JohnsonLoader
+    begin
+      require 'johnson'
+      def self.available?
+        true
+      end
+    rescue LoadError
+      def self.available?
+        false
+      end
+    end
+    attr_accessor :runtime
+    def initialize(*files)
+      files=["/pv.js","/pv-internals.js", "/data/Arrays.js","/data/Numbers.js", "/data/Scale.js", "/data/QuantitativeScale.js", "/data/LinearScale.js","/color/Color.js","/color/Colors.js","/text/Format.js", "/text/DateFormat.js","/text/NumberFormat.js","/text/TimeFormat.js"]+files
+      files.uniq!
+      files=files.map {|v| $PROTOVIS_DIR+v}
+      @runtime = Johnson.load(*files)
+    end
+  end
+end
+# Spec matcher 
+RSpec::Matchers.define :have_svg_attributes do |exp|
+  match do |obs|
+    exp.each {|k,v|
+      obs.attributes[k].should be_true
+      obs.attributes[k].value.should==v
+    }
+  end
+  failure_message_for_should do |obs|
+    "\n#{exp} attributes expected, but xml doesn't contains them \n#{obs.to_s}"
+  end
+end
+
+# Include
+# * rect
+# * circle
+# * text
+# * path
+# Using attributes and content
+RSpec::Matchers.define :have_same_svg_elements do |exp|
+  def equal_float(a,b)
+    a||=0
+    b||=0
+    (a.to_f-b.to_f).abs<0.0001
+  end
+  def equal_string_nil(a,b)
+    a||="none"
+    b||="none"
+    a.to_s==b.to_s
+  end
+  def equal_string(a,b)
+    a.to_s==b.to_s
+  end
+  def path_scan(path)
+    path.scan(/([MmCcZzLlHhVvSsQqTtAa, ])(\d+(?:\.\d+)?)/).map {|v|
+      v[0]="," if v[0]==" "
+      v[1]=v[1].to_f
+      v
+    }
+  end
+  
+  def equal_path(a,b)
+    path_a=path_scan(a)
+    path_b=path_scan(b)
+    correct=true
+    path_a.each_with_index do |v,i|
+      if (v[0]!=path_b[i][0]) or (v[1]-path_b[i][1]).abs>0.001
+        @path_error=[v[0],path_b[i][0], v[1],path_b[i][1]]
+        correct=false
+        break
+      end
+      
+    end
+    correct
+  end
+  match do |obs|
+    obs_xml=Nokogiri::XML(obs)
+    exp_xml=Nokogiri::XML(exp)
+    correct=true
+    attrs={
+      "circle"=>{'fill'=>:string_nil, 'fill-opacity'=>:float, 'cx'=>:float,'stroke'=>:string_nil, 'stroke-opacity'=>:string, 'cy'=>:float,'r'=>:float},
+      "rect"=>{"x"=>:float,"y"=>:float,"width"=>:float,"height"=>:float, 'fill'=>:string_nil, 'fill-opacity'=>:float, 'stroke'=>:string_nil, 'stroke-opacity'=>:float},
+      "text"=>{"x"=>:float,"dx"=>:float,"y"=>:float,"dy"=>:float},
+      'path'=>{'d'=>:path, 'fill'=>:string_nil, 'fill-opacity'=>:float, 'stroke'=>:string_nil, 'stroke-opacity'=>:float, 'stroke-width'=>:float}
+    }
+    
+    @error={:type=>"Undefined error"}
+    attrs.each_pair do |key,attrs|
+      exp_elements=exp_xml.xpath("//#{key}")
+      obs_elements=obs_xml.xpath("//xmlns:#{key}")
+      if exp_elements.size!=obs_elements.size
+        @error={:type=>"Different number of #{key} elements",:exp=>exp_elements.size, :obs=>obs_elements.size}
+        correct=false
+        break
+      end
+      
+      exp_elements.each_with_index {|exp_data,i|
+        obs_data=obs_elements[i]  
+        if obs_data.nil?
+          @error={:type=>"Missing obs", :exp=>exp_data, :i=>i}
+          correct=false
+          break
+        end
+        if exp_data.content!=obs_data.content
+          @error={:type=>"Content", :exp=>exp_data, :i=>i, :obs=>obs_data, :exp_attr=>exp_data.content, :obs_attr=>obs_data.content}
+          correct=false
+          break;
+        end
+        
+        attrs.each do |attr,method|
+          eq=send("equal_#{method}", obs_data[attr], exp_data[attr])
+          if !eq
+            ty=(method=='path' ? "!= path:#{@path_error.join(',')}" : "!=attr(#{method})" )
+            #puts "Uneql attr: #{method}->#{attr}"
+            @error={:type=>"!= attr", :exp=>exp_data, :obs=>obs_data, :attr=>attr, :exp_attr=>exp_data[attr], :obs_attr=>obs_data[attr],:i=>i}
+            correct=false
+            break
+          end
+        end
+        if !correct
+          break
+        end
+      }
+    end
+    correct
+  end
+  failure_message_for_should do |obs|
+    "#{@error[:type]}: #{@error[:exp].to_s} expected, but #{@error[:obs]} retrieved, on #{@error[:attr]} -> #{@error[:i]} : '#{@error[:exp_attr]}' <> '#{@error[:obs_attr]}'"
+  end
+  
+end
+RSpec::Matchers.define :have_same_position do |exp|
+  match do |obs|
+    correct=true
+    attrs={
+      "circle"=>['cx','cy','r'],
+      "rect"=>["x","y","width","height"],
+      "text"=>["x","dx","y","dy","transform"]
+    }
+    attrs[exp.name].each do |attr|
+      if (obs[attr].to_f -  exp[attr].to_f).abs>0.0001
+        correct=false
+        break
+      end
+    end
+    correct
+  end
+end
+
+
+RSpec::Matchers.define :have_path_data_close_to do |exp|
+  def path_scan(path)
+      path.scan(/([MmCcZzLlHhVvSsQqTtAa, ])(\d+(?:\.\d+)?)/).map {|v|
+      v[0]="," if v[0]==" "
+      v[1]=v[1].to_f
+      v
+      }
+  end
+  match do |obs|
+    correct=true
+    obs_array=path_scan(obs.attributes["d"].value)
+    
+    exp_array=path_scan(exp)
+    obs_array.each_with_index {|v,i|
+      if (v[0]!=exp_array[i][0]) or (v[1]-exp_array[i][1]).abs>0.001
+        correct=false
+        break
+      end
+    }
+    correct
+  end
+  failure_message_for_should do |obs|
+    obs_array=path_scan(obs.attributes["d"].value)
+    exp_array=path_scan(exp)
+    "\n#{obs_array} path should be equal to \n#{exp_array}"
+  end
+end
diff --git a/spec/vector_spec.rb b/spec/vector_spec.rb
new file mode 100644
index 0000000..22dd065
--- /dev/null
+++ b/spec/vector_spec.rb
@@ -0,0 +1,36 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Vector do
+  before do
+    @x1, at x2, at y1, at y2=rand(10)+1,rand(10)+1,rand(10)+1,rand(10)+1
+    @v1=Rubyvis::Vector.new(@x1, at y1)
+    @v2=Rubyvis::Vector.new(@x2, at y2)
+  end
+  it "should return the same as Rubyvis.vector" do
+    Rubyvis.vector(@x1, at y1).should== @v1
+  end
+  it "method perp" do
+    @v1.perp.should==Rubyvis::Vector.new(- at y1, at x1)
+  end
+  it "method times" do
+    times=rand(10)+1
+    @v1.times(times).should==Rubyvis::Vector.new(@x1*times, at y1*times)
+  end
+  it "method length" do
+    l=Math.sqrt(@x1*@x1+ at y1*@y1)
+    @v1.length.should eq l
+  end
+  it "method norm" do
+    l=@v1.length
+    @v1.norm.should==@v1.times(1/l.to_f)
+  end
+  it "method plus" do
+    @v1.plus(@v2).should==Rubyvis::Vector.new(@x1+ at x2, at y1+@y2)
+  end
+  it "method minus" do
+    @v1.minus(@v2).should==Rubyvis::Vector.new(@x1- at x2, at y1-@y2)
+  end
+  it "method dot" do
+    @v1.dot(@v2).should==@x1*@x2+ at y1*@y2
+  end
+end
+
diff --git a/spec/wedge_spec.rb b/spec/wedge_spec.rb
new file mode 100644
index 0000000..f5612b2
--- /dev/null
+++ b/spec/wedge_spec.rb
@@ -0,0 +1,66 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Wedge do
+  include Rubyvis::GeneralSpec
+  it "should have correct properties" do
+    props=[:angle, :antialias, :bottom, :cursor, :data, :end_angle, :events, :fill_style,  :id, :inner_radius, :left, :line_width, :outer_radius, :reverse, :right, :start_angle, :stroke_style, :title, :top, :visible].inject({}) {|ac, v| ac[v]=true; ac}
+    Rubyvis::Wedge.properties.should==props
+  end
+  it "Rubyvis.Wedge be the same as Rubyvis::Wedge" do
+    Rubyvis.Wedge.should eql Rubyvis::Wedge
+  end
+  it "should render equal to protovis 'wedge-anchor.html' test" do
+    
+    data = Rubyvis.range(5).map {|x| x}
+    w = 400
+    h = 400
+    r = w / 2.0
+    t = 30
+    a = Rubyvis::Scale.linear(0, Rubyvis.sum(data)).range(0, 2 * Math::PI);
+
+    vis = Rubyvis::Panel.new().
+width(w).
+height(h)
+
+    anchors=["outer","inner","start","center","end"]
+    
+    vis.add(Rubyvis::Wedge).
+data(data).
+outer_radius(r).
+angle(a).
+anchor(lambda {anchors[self.index]}).add(pv.Label).
+text(lambda {anchors[self.index]})
+
+    vis.render();
+    pv_out=fixture_svg_read("wedge_anchor.svg")
+    vis.to_svg.should have_same_svg_elements(pv_out)
+    
+  end
+  it "should render equal to protovis 'wedge-donut.html' test" do
+    data = Rubyvis.range(10).map {|x| (Math.sin(x)).abs}
+    w = 400
+    h = 400
+    r = w / 2.0
+    t = 30
+    a = Rubyvis.Scale.linear(0, Rubyvis.sum(data)).range(0, 2 * Math::PI)
+    
+    @vis = Rubyvis::Panel.new().
+width(w).
+height(h)
+    
+    @vis.add(Rubyvis::Wedge).
+data(data).
+inner_radius(r - t).
+outer_radius(r).
+angle(a).
+title(lambda {|d| d}).
+anchor("outer").add(Rubyvis::Label).
+visible(lambda {|d| d>0.05}).
+text_margin(t + 5).
+text(lambda {|d| "%0.2f" % d})
+    @vis.render();
+
+    @pv_out=fixture_svg_read("wedge_donut.svg")
+    @vis.to_svg.should have_same_svg_elements(@pv_out)
+  end  
+  
+end
\ No newline at end of file
diff --git a/vendor/protovis/protovis-r3.3.js b/vendor/protovis/protovis-r3.3.js
new file mode 100644
index 0000000..2130d5b
--- /dev/null
+++ b/vendor/protovis/protovis-r3.3.js
@@ -0,0 +1,287 @@
+// 3ec4c9b
+var a;if(!Array.prototype.map)Array.prototype.map=function(b,c){for(var d=this.length,f=new Array(d),g=0;g<d;g++)if(g in this)f[g]=b.call(c,this[g],g,this);return f};if(!Array.prototype.filter)Array.prototype.filter=function(b,c){for(var d=this.length,f=[],g=0;g<d;g++)if(g in this){var h=this[g];b.call(c,h,g,this)&&f.push(h)}return f};if(!Array.prototype.forEach)Array.prototype.forEach=function(b,c){for(var d=this.length>>>0,f=0;f<d;f++)f in this&&b.call(c,this[f],f,this)};
+if(!Array.prototype.reduce)Array.prototype.reduce=function(b,c){var d=this.length;if(!d&&arguments.length==1)throw new Error("reduce: empty array, no initial value");var f=0;if(arguments.length<2)for(;;){if(f in this){c=this[f++];break}if(++f>=d)throw new Error("reduce: no values, no initial value");}for(;f<d;f++)if(f in this)c=b(c,this[f],f,this);return c};var pv={};pv.version={major:3,minor:3};pv.identity=function(b){return b};pv.index=function(){return this.index};pv.child=function(){ [...]
+pv.parent=function(){return this.parent.index};pv.extend=function(b){function c(){}c.prototype=b.prototype||b;return new c};
+try{eval("pv.parse = function(x) x;")}catch(e){pv.parse=function(b){for(var c=new RegExp("function\\s*(\\b\\w+)?\\s*\\([^)]*\\)\\s*","mg"),d,f,g=0,h="";d=c.exec(b);){d=d.index+d[0].length;if(b.charAt(d)!="{"){h+=b.substring(g,d)+"{return ";g=d;for(var i=0;i>=0&&d<b.length;d++){var j=b.charAt(d);switch(j){case '"':case "'":for(;++d<b.length&&(f=b.charAt(d))!=j;)f=="\\"&&d++;break;case "[":case "(":i++;break;case "]":case ")":i--;break;case ";":case ",":i==0&&i--;break}}h+=pv.parse(b.subst [...]
+";}";g=d}c.lastIndex=d}h+=b.substring(g);return h}}pv.css=function(b,c){return window.getComputedStyle?window.getComputedStyle(b,null).getPropertyValue(c):b.currentStyle[c]};pv.error=function(b){typeof console=="undefined"?alert(b):console.error(b)};pv.listen=function(b,c,d){d=pv.listener(d);return b.addEventListener?b.addEventListener(c,d,false):b.attachEvent("on"+c,d)};pv.listener=function(b){return b.$listener||(b.$listener=function(c){try{pv.event=c;return b.call(this,c)}finally{dele [...]
+pv.ancestor=function(b,c){for(;c;){if(c==b)return true;c=c.parentNode}return false};pv.id=function(){var b=1;return function(){return b++}}();pv.functor=function(b){return typeof b=="function"?b:function(){return b}};pv.listen(window,"load",function(){for(pv.$={i:0,x:document.getElementsByTagName("script")};pv.$.i<pv.$.x.length;pv.$.i++){pv.$.s=pv.$.x[pv.$.i];if(pv.$.s.type=="text/javascript+protovis")try{window.eval(pv.parse(pv.$.s.text))}catch(b){pv.error(b)}}delete pv.$});pv.Format={};
+pv.Format.re=function(b){return b.replace(/[\\\^\$\*\+\?\[\]\(\)\.\{\}]/g,"\\$&")};pv.Format.pad=function(b,c,d){c=c-String(d).length;return c<1?d:(new Array(c+1)).join(b)+d};
+pv.Format.date=function(b){function c(f){return b.replace(/%[a-zA-Z0-9]/g,function(g){switch(g){case "%a":return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][f.getDay()];case "%A":return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][f.getDay()];case "%h":case "%b":return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][f.getMonth()];case "%B":return["January","February","March","April","May","June","July","August","September","October","Nov [...]
+case "%c":return f.toLocaleString();case "%C":return d("0",2,Math.floor(f.getFullYear()/100)%100);case "%d":return d("0",2,f.getDate());case "%x":case "%D":return d("0",2,f.getMonth()+1)+"/"+d("0",2,f.getDate())+"/"+d("0",2,f.getFullYear()%100);case "%e":return d(" ",2,f.getDate());case "%H":return d("0",2,f.getHours());case "%I":return(g=f.getHours()%12)?d("0",2,g):12;case "%m":return d("0",2,f.getMonth()+1);case "%M":return d("0",2,f.getMinutes());case "%n":return"\n";case "%p":return  [...]
+12?"AM":"PM";case "%T":case "%X":case "%r":g=f.getHours()%12;return(g?d("0",2,g):12)+":"+d("0",2,f.getMinutes())+":"+d("0",2,f.getSeconds())+" "+(f.getHours()<12?"AM":"PM");case "%R":return d("0",2,f.getHours())+":"+d("0",2,f.getMinutes());case "%S":return d("0",2,f.getSeconds());case "%Q":return d("0",3,f.getMilliseconds());case "%t":return"\t";case "%u":return(g=f.getDay())?g:1;case "%w":return f.getDay();case "%y":return d("0",2,f.getFullYear()%100);case "%Y":return f.getFullYear();ca [...]
+var d=pv.Format.pad;c.format=c;c.parse=function(f){var g=1970,h=0,i=1,j=0,k=0,l=0,s=[function(){}],p=pv.Format.re(b).replace(/%[a-zA-Z0-9]/g,function(q){switch(q){case "%b":s.push(function(m){h={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11}[m]});return"([A-Za-z]+)";case "%h":case "%B":s.push(function(m){h={January:0,February:1,March:2,April:3,May:4,June:5,July:6,August:7,September:8,October:9,November:10,December:11}[m]});return"([A-Za-z]+)";case "%e":case "% [...]
+m});return"([0-9]+)";case "%I":case "%H":s.push(function(m){j=m});return"([0-9]+)";case "%m":s.push(function(m){h=m-1});return"([0-9]+)";case "%M":s.push(function(m){k=m});return"([0-9]+)";case "%p":s.push(function(m){if(j==12){if(m=="am")j=0}else if(m=="pm")j=Number(j)+12});return"(am|pm)";case "%S":s.push(function(m){l=m});return"([0-9]+)";case "%y":s.push(function(m){m=Number(m);g=m+(0<=m&&m<69?2E3:m>=69&&m<100?1900:0)});return"([0-9]+)";case "%Y":s.push(function(m){g=m});return"([0-9 [...]
+return"%"}return q});(f=f.match(p))&&f.forEach(function(q,m){s[m](q)});return new Date(g,h,i,j,k,l)};return c};
+pv.Format.time=function(b){function c(f){f=Number(f);switch(b){case "short":if(f>=31536E6)return(f/31536E6).toFixed(1)+" years";else if(f>=6048E5)return(f/6048E5).toFixed(1)+" weeks";else if(f>=864E5)return(f/864E5).toFixed(1)+" days";else if(f>=36E5)return(f/36E5).toFixed(1)+" hours";else if(f>=6E4)return(f/6E4).toFixed(1)+" minutes";return(f/1E3).toFixed(1)+" seconds";case "long":var g=[],h=f%36E5/6E4>>0;g.push(d("0",2,f%6E4/1E3>>0));if(f>=36E5){var i=f%864E5/36E5>>0;g.push(d("0",2,h)) [...]
+2,i));g.push(Math.floor(f/864E5).toFixed())}else g.push(i.toFixed())}else g.push(h.toFixed());return g.reverse().join(":")}}var d=pv.Format.pad;c.format=c;c.parse=function(f){switch(b){case "short":for(var g=/([0-9,.]+)\s*([a-z]+)/g,h,i=0;h=g.exec(f);){var j=parseFloat(h[0].replace(",","")),k=0;switch(h[2].toLowerCase()){case "year":case "years":k=31536E6;break;case "week":case "weeks":k=6048E5;break;case "day":case "days":k=864E5;break;case "hour":case "hours":k=36E5;break;case "minute" [...]
+6E4;break;case "second":case "seconds":k=1E3;break}i+=j*k}return i;case "long":h=f.replace(",","").split(":").reverse();i=0;if(h.length)i+=parseFloat(h[0])*1E3;if(h.length>1)i+=parseFloat(h[1])*6E4;if(h.length>2)i+=parseFloat(h[2])*36E5;if(h.length>3)i+=parseFloat(h[3])*864E5;return i}};return c};
+pv.Format.number=function(){function b(n){if(Infinity>h)n=Math.round(n*i)/i;var r=String(Math.abs(n)).split("."),t=r[0];if(t.length>d)t=t.substring(t.length-d);if(l&&t.length<c)t=(new Array(c-t.length+1)).join(j)+t;if(t.length>3)t=t.replace(/\B(?=(?:\d{3})+(?!\d))/g,p);if(!l&&t.length<f)t=(new Array(f-t.length+1)).join(j)+t;r[0]=n<0?q+t+m:t;n=r[1]||"";if(n.length<g)r[1]=n+(new Array(g-n.length+1)).join(k);return r.join(s)}var c=0,d=Infinity,f=0,g=0,h=0,i=1,j="0",k="0",l=true,s=".",p=",", [...]
+m="";b.format=b;b.parse=function(n){var r=pv.Format.re;n=String(n).replace(new RegExp("^("+r(j)+")*"),"").replace(new RegExp("("+r(k)+")*$"),"").split(s);r=n[0].replace(new RegExp(r(p),"g"),"");if(r.length>d)r=r.substring(r.length-d);n=n[1]?Number("0."+n[1]):0;if(Infinity>h)n=Math.round(n*i)/i;return Math.round(r)+n};b.integerDigits=function(n,r){if(arguments.length){c=Number(n);d=arguments.length>1?Number(r):c;f=c+Math.floor(c/3)*p.length;return this}return[c,d]};b.fractionDigits=functi [...]
+Number(n);h=arguments.length>1?Number(r):g;i=Math.pow(10,h);return this}return[g,h]};b.integerPad=function(n){if(arguments.length){j=String(n);l=/\d/.test(j);return this}return j};b.fractionPad=function(n){if(arguments.length){k=String(n);return this}return k};b.decimal=function(n){if(arguments.length){s=String(n);return this}return s};b.group=function(n){if(arguments.length){p=n?String(n):"";f=c+Math.floor(c/3)*p.length;return this}return p};b.negativeAffix=function(n,r){if(arguments.le [...]
+"");m=String(r||"");return this}return[q,m]};return b};pv.map=function(b,c){var d={};return c?b.map(function(f,g){d.index=g;return c.call(d,f)}):b.slice()};pv.repeat=function(b,c){if(arguments.length==1)c=2;return pv.blend(pv.range(c).map(function(){return b}))};pv.cross=function(b,c){for(var d=[],f=0,g=b.length,h=c.length;f<g;f++)for(var i=0,j=b[f];i<h;i++)d.push([j,c[i]]);return d};pv.blend=function(b){return Array.prototype.concat.apply([],b)};
+pv.transpose=function(b){var c=b.length,d=pv.max(b,function(i){return i.length});if(d>c){b.length=d;for(var f=c;f<d;f++)b[f]=new Array(c);for(f=0;f<c;f++)for(var g=f+1;g<d;g++){var h=b[f][g];b[f][g]=b[g][f];b[g][f]=h}}else{for(f=0;f<d;f++)b[f].length=c;for(f=0;f<c;f++)for(g=0;g<f;g++){h=b[f][g];b[f][g]=b[g][f];b[g][f]=h}}b.length=d;for(f=0;f<d;f++)b[f].length=c;return b};pv.normalize=function(b,c){b=pv.map(b,c);c=pv.sum(b);for(var d=0;d<b.length;d++)b[d]/=c;return b};
+pv.permute=function(b,c,d){if(!d)d=pv.identity;var f=new Array(c.length),g={};c.forEach(function(h,i){g.index=h;f[i]=d.call(g,b[h])});return f};pv.numerate=function(b,c){if(!c)c=pv.identity;var d={},f={};b.forEach(function(g,h){f.index=h;d[c.call(f,g)]=h});return d};pv.uniq=function(b,c){if(!c)c=pv.identity;var d={},f=[],g={},h;b.forEach(function(i,j){g.index=j;h=c.call(g,i);h in d||(d[h]=f.push(h))});return f};pv.naturalOrder=function(b,c){return b<c?-1:b>c?1:0};
+pv.reverseOrder=function(b,c){return c<b?-1:c>b?1:0};pv.search=function(b,c,d){if(!d)d=pv.identity;for(var f=0,g=b.length-1;f<=g;){var h=f+g>>1,i=d(b[h]);if(i<c)f=h+1;else if(i>c)g=h-1;else return h}return-f-1};pv.search.index=function(b,c,d){b=pv.search(b,c,d);return b<0?-b-1:b};
+pv.range=function(b,c,d){if(arguments.length==1){c=b;b=0}if(d==undefined)d=1;if((c-b)/d==Infinity)throw new Error("range must be finite");var f=[],g=0,h;c-=(c-b)*1.0E-10;if(d<0)for(;(h=b+d*g++)>c;)f.push(h);else for(;(h=b+d*g++)<c;)f.push(h);return f};pv.random=function(b,c,d){if(arguments.length==1){c=b;b=0}if(d==undefined)d=1;return d?Math.floor(Math.random()*(c-b)/d)*d+b:Math.random()*(c-b)+b};
+pv.sum=function(b,c){var d={};return b.reduce(c?function(f,g,h){d.index=h;return f+c.call(d,g)}:function(f,g){return f+g},0)};pv.max=function(b,c){if(c==pv.index)return b.length-1;return Math.max.apply(null,c?pv.map(b,c):b)};pv.max.index=function(b,c){if(!b.length)return-1;if(c==pv.index)return b.length-1;if(!c)c=pv.identity;for(var d=0,f=-Infinity,g={},h=0;h<b.length;h++){g.index=h;var i=c.call(g,b[h]);if(i>f){f=i;d=h}}return d};
+pv.min=function(b,c){if(c==pv.index)return 0;return Math.min.apply(null,c?pv.map(b,c):b)};pv.min.index=function(b,c){if(!b.length)return-1;if(c==pv.index)return 0;if(!c)c=pv.identity;for(var d=0,f=Infinity,g={},h=0;h<b.length;h++){g.index=h;var i=c.call(g,b[h]);if(i<f){f=i;d=h}}return d};pv.mean=function(b,c){return pv.sum(b,c)/b.length};
+pv.median=function(b,c){if(c==pv.index)return(b.length-1)/2;b=pv.map(b,c).sort(pv.naturalOrder);if(b.length%2)return b[Math.floor(b.length/2)];c=b.length/2;return(b[c-1]+b[c])/2};pv.variance=function(b,c){if(b.length<1)return NaN;if(b.length==1)return 0;var d=pv.mean(b,c),f=0,g={};if(!c)c=pv.identity;for(var h=0;h<b.length;h++){g.index=h;var i=c.call(g,b[h])-d;f+=i*i}return f};pv.deviation=function(b,c){return Math.sqrt(pv.variance(b,c)/(b.length-1))};pv.log=function(b,c){return Math.log [...]
+pv.logSymmetric=function(b,c){return b==0?0:b<0?-pv.log(-b,c):pv.log(b,c)};pv.logAdjusted=function(b,c){if(!isFinite(b))return b;var d=b<0;if(b<c)b+=(c-b)/c;return d?-pv.log(b,c):pv.log(b,c)};pv.logFloor=function(b,c){return b>0?Math.pow(c,Math.floor(pv.log(b,c))):-Math.pow(c,-Math.floor(-pv.log(-b,c)))};pv.logCeil=function(b,c){return b>0?Math.pow(c,Math.ceil(pv.log(b,c))):-Math.pow(c,-Math.ceil(-pv.log(-b,c)))};
+(function(){var b=Math.PI/180,c=180/Math.PI;pv.radians=function(d){return b*d};pv.degrees=function(d){return c*d}})();pv.keys=function(b){var c=[];for(var d in b)c.push(d);return c};pv.entries=function(b){var c=[];for(var d in b)c.push({key:d,value:b[d]});return c};pv.values=function(b){var c=[];for(var d in b)c.push(b[d]);return c};pv.dict=function(b,c){for(var d={},f={},g=0;g<b.length;g++)if(g in b){var h=b[g];f.index=g;d[h]=c.call(f,h)}return d};pv.dom=function(b){return new pv.Dom(b)};
+pv.Dom=function(b){this.$map=b};pv.Dom.prototype.$leaf=function(b){return typeof b!="object"};pv.Dom.prototype.leaf=function(b){if(arguments.length){this.$leaf=b;return this}return this.$leaf};pv.Dom.prototype.root=function(b){function c(g){var h=new pv.Dom.Node;for(var i in g){var j=g[i];h.appendChild(d(j)?new pv.Dom.Node(j):c(j)).nodeName=i}return h}var d=this.$leaf,f=c(this.$map);f.nodeName=b;return f};pv.Dom.prototype.nodes=function(){return this.root().nodes()};
+pv.Dom.Node=function(b){this.nodeValue=b;this.childNodes=[]};a=pv.Dom.Node.prototype;a.parentNode=null;a.firstChild=null;a.lastChild=null;a.previousSibling=null;a.nextSibling=null;
+a.removeChild=function(b){var c=this.childNodes.indexOf(b);if(c==-1)throw new Error("child not found");this.childNodes.splice(c,1);if(b.previousSibling)b.previousSibling.nextSibling=b.nextSibling;else this.firstChild=b.nextSibling;if(b.nextSibling)b.nextSibling.previousSibling=b.previousSibling;else this.lastChild=b.previousSibling;delete b.nextSibling;delete b.previousSibling;delete b.parentNode;return b};
+a.appendChild=function(b){b.parentNode&&b.parentNode.removeChild(b);b.parentNode=this;if(b.previousSibling=this.lastChild)this.lastChild.nextSibling=b;else this.firstChild=b;this.lastChild=b;this.childNodes.push(b);return b};
+a.insertBefore=function(b,c){if(!c)return this.appendChild(b);var d=this.childNodes.indexOf(c);if(d==-1)throw new Error("child not found");b.parentNode&&b.parentNode.removeChild(b);b.parentNode=this;b.nextSibling=c;if(b.previousSibling=c.previousSibling)c.previousSibling.nextSibling=b;else{if(c==this.lastChild)this.lastChild=b;this.firstChild=b}this.childNodes.splice(d,0,b);return b};
+a.replaceChild=function(b,c){var d=this.childNodes.indexOf(c);if(d==-1)throw new Error("child not found");b.parentNode&&b.parentNode.removeChild(b);b.parentNode=this;b.nextSibling=c.nextSibling;if(b.previousSibling=c.previousSibling)c.previousSibling.nextSibling=b;else this.firstChild=b;if(c.nextSibling)c.nextSibling.previousSibling=b;else this.lastChild=b;this.childNodes[d]=b;return c};a.visitBefore=function(b){function c(d,f){b(d,f);for(d=d.firstChild;d;d=d.nextSibling)c(d,f+1)}c(this,0)};
+a.visitAfter=function(b){function c(d,f){for(var g=d.firstChild;g;g=g.nextSibling)c(g,f+1);b(d,f)}c(this,0)};a.sort=function(b){if(this.firstChild){this.childNodes.sort(b);var c=this.firstChild=this.childNodes[0],d;delete c.previousSibling;for(var f=1;f<this.childNodes.length;f++){c.sort(b);d=this.childNodes[f];d.previousSibling=c;c=c.nextSibling=d}this.lastChild=c;delete c.nextSibling;c.sort(b)}return this};
+a.reverse=function(){var b=[];this.visitAfter(function(c){for(;c.lastChild;)b.push(c.removeChild(c.lastChild));for(var d;d=b.pop();)c.insertBefore(d,c.firstChild)});return this};a.nodes=function(){function b(d){c.push(d);d.childNodes.forEach(b)}var c=[];b(this,c);return c};
+a.toggle=function(b){if(b)return this.toggled?this.visitBefore(function(d){d.toggled&&d.toggle()}):this.visitAfter(function(d){d.toggled||d.toggle()});b=this;if(b.toggled){for(var c;c=b.toggled.pop();)b.appendChild(c);delete b.toggled}else if(b.lastChild)for(b.toggled=[];b.lastChild;)b.toggled.push(b.removeChild(b.lastChild))};pv.nodes=function(b){for(var c=new pv.Dom.Node,d=0;d<b.length;d++)c.appendChild(new pv.Dom.Node(b[d]));return c.nodes()};pv.tree=function(b){return new pv.Tree(b)};
+pv.Tree=function(b){this.array=b};pv.Tree.prototype.keys=function(b){this.k=b;return this};pv.Tree.prototype.value=function(b){this.v=b;return this};pv.Tree.prototype.map=function(){for(var b={},c={},d=0;d<this.array.length;d++){c.index=d;for(var f=this.array[d],g=this.k.call(c,f),h=b,i=0;i<g.length-1;i++)h=h[g[i]]||(h[g[i]]={});h[g[i]]=this.v?this.v.call(c,f):f}return b};pv.nest=function(b){return new pv.Nest(b)};pv.Nest=function(b){this.array=b;this.keys=[]};a=pv.Nest.prototype;
+a.key=function(b){this.keys.push(b);return this};a.sortKeys=function(b){this.keys[this.keys.length-1].order=b||pv.naturalOrder;return this};a.sortValues=function(b){this.order=b||pv.naturalOrder;return this};a.map=function(){for(var b={},c=[],d,f=0;f<this.array.length;f++){var g=this.array[f],h=b;for(d=0;d<this.keys.length-1;d++){var i=this.keys[d](g);h[i]||(h[i]={});h=h[i]}i=this.keys[d](g);if(!h[i]){d=[];c.push(d);h[i]=d}h[i].push(g)}if(this.order)for(d=0;d<c.length;d++)c[d].sort(this. [...]
+a.entries=function(){function b(d){var f=[];for(var g in d){var h=d[g];f.push({key:g,values:h instanceof Array?h:b(h)})}return f}function c(d,f){var g=this.keys[f].order;g&&d.sort(function(i,j){return g(i.key,j.key)});if(++f<this.keys.length)for(var h=0;h<d.length;h++)c.call(this,d[h].values,f);return d}return c.call(this,b(this.map()),0)};a.rollup=function(b){function c(d){for(var f in d){var g=d[f];if(g instanceof Array)d[f]=b(g);else c(g)}return d}return c(this.map())};pv.flatten=func [...]
+pv.Flatten=function(b){this.map=b;this.keys=[]};pv.Flatten.prototype.key=function(b,c){this.keys.push({name:b,value:c});delete this.$leaf;return this};pv.Flatten.prototype.leaf=function(b){this.keys.length=0;this.$leaf=b;return this};
+pv.Flatten.prototype.array=function(){function b(i,j){if(j<f.length-1)for(var k in i){d.push(k);b(i[k],j+1);d.pop()}else c.push(d.concat(i))}var c=[],d=[],f=this.keys,g=this.$leaf;if(g){function h(i,j){if(g(i))c.push({keys:d.slice(),value:i});else for(var k in i){d.push(k);h(i[k],j+1);d.pop()}}h(this.map,0);return c}b(this.map,0);return c.map(function(i){for(var j={},k=0;k<f.length;k++){var l=f[k],s=i[k];j[l.name]=l.value?l.value.call(null,s):s}return j})};
+pv.vector=function(b,c){return new pv.Vector(b,c)};pv.Vector=function(b,c){this.x=b;this.y=c};a=pv.Vector.prototype;a.perp=function(){return new pv.Vector(-this.y,this.x)};a.norm=function(){var b=this.length();return this.times(b?1/b:1)};a.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};a.times=function(b){return new pv.Vector(this.x*b,this.y*b)};a.plus=function(b,c){return arguments.length==1?new pv.Vector(this.x+b.x,this.y+b.y):new pv.Vector(this.x+b,this.y+c)};
+a.minus=function(b,c){return arguments.length==1?new pv.Vector(this.x-b.x,this.y-b.y):new pv.Vector(this.x-b,this.y-c)};a.dot=function(b,c){return arguments.length==1?this.x*b.x+this.y*b.y:this.x*b+this.y*c};pv.Transform=function(){};pv.Transform.prototype={k:1,x:0,y:0};pv.Transform.identity=new pv.Transform;pv.Transform.prototype.translate=function(b,c){var d=new pv.Transform;d.k=this.k;d.x=this.k*b+this.x;d.y=this.k*c+this.y;return d};
+pv.Transform.prototype.scale=function(b){var c=new pv.Transform;c.k=this.k*b;c.x=this.x;c.y=this.y;return c};pv.Transform.prototype.invert=function(){var b=new pv.Transform,c=1/this.k;b.k=c;b.x=-this.x*c;b.y=-this.y*c;return b};pv.Transform.prototype.times=function(b){var c=new pv.Transform;c.k=this.k*b.k;c.x=this.k*b.x+this.x;c.y=this.k*b.y+this.y;return c};pv.Scale=function(){};
+pv.Scale.interpolator=function(b,c){if(typeof b=="number")return function(d){return d*(c-b)+b};b=pv.color(b).rgb();c=pv.color(c).rgb();return function(d){var f=b.a*(1-d)+c.a*d;if(f<1.0E-5)f=0;return b.a==0?pv.rgb(c.r,c.g,c.b,f):c.a==0?pv.rgb(b.r,b.g,b.b,f):pv.rgb(Math.round(b.r*(1-d)+c.r*d),Math.round(b.g*(1-d)+c.g*d),Math.round(b.b*(1-d)+c.b*d),f)}};
+pv.Scale.quantitative=function(){function b(p){return new Date(p)}function c(p){var q=pv.search(d,p);if(q<0)q=-q-2;q=Math.max(0,Math.min(h.length-1,q));return h[q]((k(p)-f[q])/(f[q+1]-f[q]))}var d=[0,1],f=[0,1],g=[0,1],h=[pv.identity],i=Number,j=false,k=pv.identity,l=pv.identity,s=String;c.transform=function(p,q){k=function(m){return j?-p(-m):p(m)};l=function(m){return j?-q(-m):q(m)};f=d.map(k);return this};c.domain=function(p,q,m){if(arguments.length){var n;if(p instanceof Array){if(arg [...]
+2)q=pv.identity;if(arguments.length<3)m=q;n=p.length&&q(p[0]);d=p.length?[pv.min(p,q),pv.max(p,m)]:[]}else{n=p;d=Array.prototype.slice.call(arguments).map(Number)}if(d.length){if(d.length==1)d=[d[0],d[0]]}else d=[-Infinity,Infinity];j=(d[0]||d[d.length-1])<0;f=d.map(k);i=n instanceof Date?b:Number;return this}return d.map(i)};c.range=function(){if(arguments.length){g=Array.prototype.slice.call(arguments);if(g.length){if(g.length==1)g=[g[0],g[0]]}else g=[-Infinity,Infinity];h=[];for(var p [...]
+1;p++)h.push(pv.Scale.interpolator(g[p],g[p+1]));return this}return g};c.invert=function(p){var q=pv.search(g,p);if(q<0)q=-q-2;q=Math.max(0,Math.min(h.length-1,q));return i(l(f[q]+(p-g[q])/(g[q+1]-g[q])*(f[q+1]-f[q])))};c.ticks=function(p){var q=d[0],m=d[d.length-1],n=m<q,r=n?m:q;m=n?q:m;var t=m-r;if(!t||!isFinite(t)){if(i==b)s=pv.Format.date("%x");return[i(r)]}if(i==b){function x(w,y){switch(y){case 31536E6:w.setMonth(0);case 2592E6:w.setDate(1);case 6048E5:y==6048E5&&w.setDate(w.getDat [...]
+case 864E5:w.setHours(0);case 36E5:w.setMinutes(0);case 6E4:w.setSeconds(0);case 1E3:w.setMilliseconds(0)}}var u,o,v=1;if(t>=94608E6){q=31536E6;u="%Y";o=function(w){w.setFullYear(w.getFullYear()+v)}}else if(t>=7776E6){q=2592E6;u="%m/%Y";o=function(w){w.setMonth(w.getMonth()+v)}}else if(t>=18144E5){q=6048E5;u="%m/%d";o=function(w){w.setDate(w.getDate()+7*v)}}else if(t>=2592E5){q=864E5;u="%m/%d";o=function(w){w.setDate(w.getDate()+v)}}else if(t>=108E5){q=36E5;u="%I:%M %p";o=function(w){w.s [...]
+v)}}else if(t>=18E4){q=6E4;u="%I:%M %p";o=function(w){w.setMinutes(w.getMinutes()+v)}}else if(t>=3E3){q=1E3;u="%I:%M:%S";o=function(w){w.setSeconds(w.getSeconds()+v)}}else{q=1;u="%S.%Qs";o=function(w){w.setTime(w.getTime()+v)}}s=pv.Format.date(u);r=new Date(r);u=[];x(r,q);t=t/q;if(t>10)switch(q){case 36E5:v=t>20?6:3;r.setHours(Math.floor(r.getHours()/v)*v);break;case 2592E6:v=3;r.setMonth(Math.floor(r.getMonth()/v)*v);break;case 6E4:v=t>30?15:t>15?10:5;r.setMinutes(Math.floor(r.getMinute [...]
+break;case 1E3:v=t>90?15:t>60?10:5;r.setSeconds(Math.floor(r.getSeconds()/v)*v);break;case 1:v=t>1E3?250:t>200?100:t>100?50:t>50?25:5;r.setMilliseconds(Math.floor(r.getMilliseconds()/v)*v);break;default:v=pv.logCeil(t/15,10);if(t/v<2)v/=5;else if(t/v<5)v/=2;r.setFullYear(Math.floor(r.getFullYear()/v)*v);break}for(;;){o(r);if(r>m)break;u.push(new Date(r))}return n?u.reverse():u}arguments.length||(p=10);v=pv.logFloor(t/p,10);q=p/(t/v);if(q<=0.15)v*=10;else if(q<=0.35)v*=5;else if(q<=0.75)v [...]
+v)*v;m=Math.floor(m/v)*v;s=pv.Format.number().fractionDigits(Math.max(0,-Math.floor(pv.log(v,10)+0.01)));m=pv.range(q,m+v,v);return n?m.reverse():m};c.tickFormat=function(p){return s(p)};c.nice=function(){if(d.length!=2)return this;var p=d[0],q=d[d.length-1],m=q<p,n=m?q:p;p=m?p:q;q=p-n;if(!q||!isFinite(q))return this;q=Math.pow(10,Math.round(Math.log(q)/Math.log(10))-1);d=[Math.floor(n/q)*q,Math.ceil(p/q)*q];m&&d.reverse();f=d.map(k);return this};c.by=function(p){function q(){return c(p. [...]
+arguments))}for(var m in c)q[m]=c[m];return q};c.domain.apply(c,arguments);return c};pv.Scale.linear=function(){var b=pv.Scale.quantitative();b.domain.apply(b,arguments);return b};
+pv.Scale.log=function(){var b=pv.Scale.quantitative(1,10),c,d,f=function(h){return Math.log(h)/d},g=function(h){return Math.pow(c,h)};b.ticks=function(){var h=b.domain(),i=h[0]<0,j=Math.floor(i?-f(-h[0]):f(h[0])),k=Math.ceil(i?-f(-h[1]):f(h[1])),l=[];if(i)for(l.push(-g(-j));j++<k;)for(i=c-1;i>0;i--)l.push(-g(-j)*i);else{for(;j<k;j++)for(i=1;i<c;i++)l.push(g(j)*i);l.push(g(j))}for(j=0;l[j]<h[0];j++);for(k=l.length;l[k-1]>h[1];k--);return l.slice(j,k)};b.tickFormat=function(h){return h.toP [...]
+b.nice=function(){var h=b.domain();return b.domain(pv.logFloor(h[0],c),pv.logCeil(h[1],c))};b.base=function(h){if(arguments.length){c=Number(h);d=Math.log(c);b.transform(f,g);return this}return c};b.domain.apply(b,arguments);return b.base(10)};pv.Scale.root=function(){var b=pv.Scale.quantitative();b.power=function(c){if(arguments.length){var d=Number(c),f=1/d;b.transform(function(g){return Math.pow(g,f)},function(g){return Math.pow(g,d)});return this}return d};b.domain.apply(b,arguments) [...]
+pv.Scale.ordinal=function(){function b(g){g in d||(d[g]=c.push(g)-1);return f[d[g]%f.length]}var c=[],d={},f=[];b.domain=function(g,h){if(arguments.length){g=g instanceof Array?arguments.length>1?pv.map(g,h):g:Array.prototype.slice.call(arguments);c=[];for(var i={},j=0;j<g.length;j++){var k=g[j];if(!(k in i)){i[k]=true;c.push(k)}}d=pv.numerate(c);return this}return c};b.range=function(g,h){if(arguments.length){f=g instanceof Array?arguments.length>1?pv.map(g,h):g:Array.prototype.slice.ca [...]
+if(typeof f[0]=="string")f=f.map(pv.color);return this}return f};b.split=function(g,h){var i=(h-g)/this.domain().length;f=pv.range(g+i/2,h,i);return this};b.splitFlush=function(g,h){var i=this.domain().length,j=(h-g)/(i-1);f=i==1?[(g+h)/2]:pv.range(g,h+j/2,j);return this};b.splitBanded=function(g,h,i){if(arguments.length<3)i=1;if(i<0){var j=this.domain().length;j=(h-g- -i*j)/(j+1);f=pv.range(g+j,h,j-i);f.band=-i}else{j=(h-g)/(this.domain().length+(1-i));f=pv.range(g+j*(1-i),h,j);f.band=j [...]
+b.by=function(g){function h(){return b(g.apply(this,arguments))}for(var i in b)h[i]=b[i];return h};b.domain.apply(b,arguments);return b};
+pv.Scale.quantile=function(){function b(i){return h(Math.max(0,Math.min(d,pv.search.index(f,i)-1))/d)}var c=-1,d=-1,f=[],g=[],h=pv.Scale.linear();b.quantiles=function(i){if(arguments.length){c=Number(i);if(c<0){f=[g[0]].concat(g);d=g.length-1}else{f=[];f[0]=g[0];for(var j=1;j<=c;j++)f[j]=g[~~(j*(g.length-1)/c)];d=c-1}return this}return f};b.domain=function(i,j){if(arguments.length){g=i instanceof Array?pv.map(i,j):Array.prototype.slice.call(arguments);g.sort(pv.naturalOrder);b.quantiles( [...]
+b.range=function(){if(arguments.length){h.range.apply(h,arguments);return this}return h.range()};b.by=function(i){function j(){return b(i.apply(this,arguments))}for(var k in b)j[k]=b[k];return j};b.domain.apply(b,arguments);return b};
+pv.histogram=function(b,c){var d=true;return{bins:function(f){var g=pv.map(b,c),h=[];arguments.length||(f=pv.Scale.linear(g).ticks());for(var i=0;i<f.length-1;i++){var j=h[i]=[];j.x=f[i];j.dx=f[i+1]-f[i];j.y=0}for(i=0;i<g.length;i++){j=pv.search.index(f,g[i])-1;j=h[Math.max(0,Math.min(h.length-1,j))];j.y++;j.push(b[i])}if(!d)for(i=0;i<h.length;i++)h[i].y/=g.length;return h},frequency:function(f){if(arguments.length){d=Boolean(f);return this}return d}}};
+pv.color=function(b){if(b.rgb)return b.rgb();var c=/([a-z]+)\((.*)\)/i.exec(b);if(c){var d=c[2].split(","),f=1;switch(c[1]){case "hsla":case "rgba":f=parseFloat(d[3]);if(!f)return pv.Color.transparent;break}switch(c[1]){case "hsla":case "hsl":b=parseFloat(d[0]);var g=parseFloat(d[1])/100;d=parseFloat(d[2])/100;return(new pv.Color.Hsl(b,g,d,f)).rgb();case "rgba":case "rgb":function h(k){var l=parseFloat(k);return k[k.length-1]=="%"?Math.round(l*2.55):l}g=h(d[0]);var i=h(d[1]),j=h(d[2]);re [...]
+i,j,f)}}if(f=pv.Color.names[b])return f;if(b.charAt(0)=="#"){if(b.length==4){g=b.charAt(1);g+=g;i=b.charAt(2);i+=i;j=b.charAt(3);j+=j}else if(b.length==7){g=b.substring(1,3);i=b.substring(3,5);j=b.substring(5,7)}return pv.rgb(parseInt(g,16),parseInt(i,16),parseInt(j,16),1)}return new pv.Color(b,1)};pv.Color=function(b,c){this.color=b;this.opacity=c};pv.Color.prototype.brighter=function(b){return this.rgb().brighter(b)};pv.Color.prototype.darker=function(b){return this.rgb().darker(b)};
+pv.rgb=function(b,c,d,f){return new pv.Color.Rgb(b,c,d,arguments.length==4?f:1)};pv.Color.Rgb=function(b,c,d,f){pv.Color.call(this,f?"rgb("+b+","+c+","+d+")":"none",f);this.r=b;this.g=c;this.b=d;this.a=f};pv.Color.Rgb.prototype=pv.extend(pv.Color);a=pv.Color.Rgb.prototype;a.red=function(b){return pv.rgb(b,this.g,this.b,this.a)};a.green=function(b){return pv.rgb(this.r,b,this.b,this.a)};a.blue=function(b){return pv.rgb(this.r,this.g,b,this.a)};
+a.alpha=function(b){return pv.rgb(this.r,this.g,this.b,b)};a.rgb=function(){return this};a.brighter=function(b){b=Math.pow(0.7,arguments.length?b:1);var c=this.r,d=this.g,f=this.b;if(!c&&!d&&!f)return pv.rgb(30,30,30,this.a);if(c&&c<30)c=30;if(d&&d<30)d=30;if(f&&f<30)f=30;return pv.rgb(Math.min(255,Math.floor(c/b)),Math.min(255,Math.floor(d/b)),Math.min(255,Math.floor(f/b)),this.a)};
+a.darker=function(b){b=Math.pow(0.7,arguments.length?b:1);return pv.rgb(Math.max(0,Math.floor(b*this.r)),Math.max(0,Math.floor(b*this.g)),Math.max(0,Math.floor(b*this.b)),this.a)};pv.hsl=function(b,c,d,f){return new pv.Color.Hsl(b,c,d,arguments.length==4?f:1)};pv.Color.Hsl=function(b,c,d,f){pv.Color.call(this,"hsl("+b+","+c*100+"%,"+d*100+"%)",f);this.h=b;this.s=c;this.l=d;this.a=f};pv.Color.Hsl.prototype=pv.extend(pv.Color);a=pv.Color.Hsl.prototype;
+a.hue=function(b){return pv.hsl(b,this.s,this.l,this.a)};a.saturation=function(b){return pv.hsl(this.h,b,this.l,this.a)};a.lightness=function(b){return pv.hsl(this.h,this.s,b,this.a)};a.alpha=function(b){return pv.hsl(this.h,this.s,this.l,b)};
+a.rgb=function(){function b(j){if(j>360)j-=360;else if(j<0)j+=360;if(j<60)return i+(h-i)*j/60;if(j<180)return h;if(j<240)return i+(h-i)*(240-j)/60;return i}function c(j){return Math.round(b(j)*255)}var d=this.h,f=this.s,g=this.l;d%=360;if(d<0)d+=360;f=Math.max(0,Math.min(f,1));g=Math.max(0,Math.min(g,1));var h=g<=0.5?g*(1+f):g+f-g*f,i=2*g-h;return pv.rgb(c(d+120),c(d),c(d-120),this.a)};
+pv.Color.names={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9", [...]
+darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gains [...]
+ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lig [...]
+lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5 [...]
+moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460 [...]
+seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",transparent:pv.Color.transparent=pv.rgb(0,0,0,0)};(function(){var b=pv.Color.names;for(var c in b)b[c]=pv.color [...]
+pv.colors=function(){var b=pv.Scale.ordinal();b.range.apply(b,arguments);return b};pv.Colors={};pv.Colors.category10=function(){var b=pv.colors("#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf");b.domain.apply(b,arguments);return b};
+pv.Colors.category20=function(){var b=pv.colors("#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5");b.domain.apply(b,arguments);return b};
+pv.Colors.category19=function(){var b=pv.colors("#9c9ede","#7375b5","#4a5584","#cedb9c","#b5cf6b","#8ca252","#637939","#e7cb94","#e7ba52","#bd9e39","#8c6d31","#e7969c","#d6616b","#ad494a","#843c39","#de9ed6","#ce6dbd","#a55194","#7b4173");b.domain.apply(b,arguments);return b};pv.ramp=function(){var b=pv.Scale.linear();b.range.apply(b,arguments);return b};
+pv.Scene=pv.SvgScene={svg:"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/xmlns",xlink:"http://www.w3.org/1999/xlink",xhtml:"http://www.w3.org/1999/xhtml",scale:1,events:["DOMMouseScroll","mousewheel","mousedown","mouseup","mouseover","mouseout","mousemove","click","dblclick"],implicit:{svg:{"shape-rendering":"auto","pointer-events":"painted",x:0,y:0,dy:0,"text-anchor":"start",transform:"translate(0,0)",fill:"none","fill-opacity":1,stroke:"none","stroke-opacity":1,"stroke-widt [...]
+css:{font:"10px sans-serif"}}};pv.SvgScene.updateAll=function(b){if(b.length&&b[0].reverse&&b.type!="line"&&b.type!="area"){for(var c=pv.extend(b),d=0,f=b.length-1;f>=0;d++,f--)c[d]=b[f];b=c}this.removeSiblings(this[b.type](b))};pv.SvgScene.create=function(b){return document.createElementNS(this.svg,b)};
+pv.SvgScene.expect=function(b,c,d,f){if(b){if(b.tagName=="a")b=b.firstChild;if(b.tagName!=c){c=this.create(c);b.parentNode.replaceChild(c,b);b=c}}else b=this.create(c);for(var g in d){c=d[g];if(c==this.implicit.svg[g])c=null;c==null?b.removeAttribute(g):b.setAttribute(g,c)}for(g in f){c=f[g];if(c==this.implicit.css[g])c=null;if(c==null)b.style.removeProperty(g);else b.style[g]=c}return b};
+pv.SvgScene.append=function(b,c,d){b.$scene={scenes:c,index:d};b=this.title(b,c[d]);b.parentNode||c.$g.appendChild(b);return b.nextSibling};pv.SvgScene.title=function(b,c){var d=b.parentNode;if(d&&d.tagName!="a")d=null;if(c.title){if(!d){d=this.create("a");b.parentNode&&b.parentNode.replaceChild(d,b);d.appendChild(b)}d.setAttributeNS(this.xlink,"title",c.title);return d}d&&d.parentNode.replaceChild(b,d);return b};
+pv.SvgScene.dispatch=pv.listener(function(b){var c=b.target.$scene;if(c){var d=b.type;switch(d){case "DOMMouseScroll":d="mousewheel";b.wheel=-480*b.detail;break;case "mousewheel":b.wheel=(window.opera?12:1)*b.wheelDelta;break}pv.Mark.dispatch(d,c.scenes,c.index)&&b.preventDefault()}});pv.SvgScene.removeSiblings=function(b){for(;b;){var c=b.nextSibling;b.parentNode.removeChild(b);b=c}};pv.SvgScene.undefined=function(){};
+pv.SvgScene.pathBasis=function(){function b(f,g,h,i,j){return{x:f[0]*g.left+f[1]*h.left+f[2]*i.left+f[3]*j.left,y:f[0]*g.top+f[1]*h.top+f[2]*i.top+f[3]*j.top}}var c=[[1/6,2/3,1/6,0],[0,2/3,1/3,0],[0,1/3,2/3,0],[0,1/6,2/3,1/6]],d=function(f,g,h,i){var j=b(c[1],f,g,h,i),k=b(c[2],f,g,h,i);f=b(c[3],f,g,h,i);return"C"+j.x+","+j.y+","+k.x+","+k.y+","+f.x+","+f.y};d.segment=function(f,g,h,i){var j=b(c[0],f,g,h,i),k=b(c[1],f,g,h,i),l=b(c[2],f,g,h,i);f=b(c[3],f,g,h,i);return"M"+j.x+","+j.y+"C"+k. [...]
+","+l.x+","+l.y+","+f.x+","+f.y};return d}();pv.SvgScene.curveBasis=function(b){if(b.length<=2)return"";var c="",d=b[0],f=d,g=d,h=b[1];c+=this.pathBasis(d,f,g,h);for(var i=2;i<b.length;i++){d=f;f=g;g=h;h=b[i];c+=this.pathBasis(d,f,g,h)}c+=this.pathBasis(f,g,h,h);c+=this.pathBasis(g,h,h,h);return c};
+pv.SvgScene.curveBasisSegments=function(b){if(b.length<=2)return"";var c=[],d=b[0],f=d,g=d,h=b[1],i=this.pathBasis.segment(d,f,g,h);d=f;f=g;g=h;h=b[2];c.push(i+this.pathBasis(d,f,g,h));for(i=3;i<b.length;i++){d=f;f=g;g=h;h=b[i];c.push(this.pathBasis.segment(d,f,g,h))}c.push(this.pathBasis.segment(f,g,h,h)+this.pathBasis(g,h,h,h));return c};
+pv.SvgScene.curveHermite=function(b,c){if(c.length<1||b.length!=c.length&&b.length!=c.length+2)return"";var d=b.length!=c.length,f="",g=b[0],h=b[1],i=c[0],j=i,k=1;if(d){f+="Q"+(h.left-i.x*2/3)+","+(h.top-i.y*2/3)+","+h.left+","+h.top;g=b[1];k=2}if(c.length>1){j=c[1];h=b[k];k++;f+="C"+(g.left+i.x)+","+(g.top+i.y)+","+(h.left-j.x)+","+(h.top-j.y)+","+h.left+","+h.top;for(g=2;g<c.length;g++,k++){h=b[k];j=c[g];f+="S"+(h.left-j.x)+","+(h.top-j.y)+","+h.left+","+h.top}}if(d){b=b[k];f+="Q"+(h.l [...]
+3)+","+(h.top+j.y*2/3)+","+b.left+","+b.top}return f};
+pv.SvgScene.curveHermiteSegments=function(b,c){if(c.length<1||b.length!=c.length&&b.length!=c.length+2)return[];var d=b.length!=c.length,f=[],g=b[0],h=g,i=c[0],j=i,k=1;if(d){h=b[1];f.push("M"+g.left+","+g.top+"Q"+(h.left-j.x*2/3)+","+(h.top-j.y*2/3)+","+h.left+","+h.top);k=2}for(var l=1;l<c.length;l++,k++){g=h;i=j;h=b[k];j=c[l];f.push("M"+g.left+","+g.top+"C"+(g.left+i.x)+","+(g.top+i.y)+","+(h.left-j.x)+","+(h.top-j.y)+","+h.left+","+h.top)}if(d){b=b[k];f.push("M"+h.left+","+h.top+"Q"+( [...]
+2/3)+","+(h.top+j.y*2/3)+","+b.left+","+b.top)}return f};pv.SvgScene.cardinalTangents=function(b,c){var d=[];c=(1-c)/2;for(var f=b[0],g=b[1],h=b[2],i=3;i<b.length;i++){d.push({x:c*(h.left-f.left),y:c*(h.top-f.top)});f=g;g=h;h=b[i]}d.push({x:c*(h.left-f.left),y:c*(h.top-f.top)});return d};pv.SvgScene.curveCardinal=function(b,c){if(b.length<=2)return"";return this.curveHermite(b,this.cardinalTangents(b,c))};
+pv.SvgScene.curveCardinalSegments=function(b,c){if(b.length<=2)return"";return this.curveHermiteSegments(b,this.cardinalTangents(b,c))};
+pv.SvgScene.monotoneTangents=function(b){var c=[],d=[],f=[],g=[],h=0;for(h=0;h<b.length-1;h++)d[h]=(b[h+1].top-b[h].top)/(b[h+1].left-b[h].left);f[0]=d[0];g[0]=b[1].left-b[0].left;for(h=1;h<b.length-1;h++){f[h]=(d[h-1]+d[h])/2;g[h]=(b[h+1].left-b[h-1].left)/2}f[h]=d[h-1];g[h]=b[h].left-b[h-1].left;for(h=0;h<b.length-1;h++)if(d[h]==0){f[h]=0;f[h+1]=0}for(h=0;h<b.length-1;h++)if(!(Math.abs(f[h])<1.0E-5||Math.abs(f[h+1])<1.0E-5)){var i=f[h]/d[h],j=f[h+1]/d[h],k=i*i+j*j;if(k>9){k=3/Math.sqrt [...]
+k*i*d[h];f[h+1]=k*j*d[h]}}for(h=0;h<b.length;h++){d=1+f[h]*f[h];c.push({x:g[h]/3/d,y:f[h]*g[h]/3/d})}return c};pv.SvgScene.curveMonotone=function(b){if(b.length<=2)return"";return this.curveHermite(b,this.monotoneTangents(b))};pv.SvgScene.curveMonotoneSegments=function(b){if(b.length<=2)return"";return this.curveHermiteSegments(b,this.monotoneTangents(b))};
+pv.SvgScene.area=function(b){function c(p,q){for(var m=[],n=[],r=q;p<=r;p++,q--){var t=b[p],x=b[q];t=t.left+","+t.top;x=x.left+x.width+","+(x.top+x.height);if(p<r){var u=b[p+1],o=b[q-1];switch(g.interpolate){case "step-before":t+="V"+u.top;x+="H"+(o.left+o.width);break;case "step-after":t+="H"+u.left;x+="V"+(o.top+o.height);break}}m.push(t);n.push(x)}return m.concat(n).join("L")}function d(p,q){for(var m=[],n=[],r=q;p<=r;p++,q--){var t=b[q];m.push(b[p]);n.push({left:t.left+t.width,top:t. [...]
+"basis"){p=pv.SvgScene.curveBasis(m);q=pv.SvgScene.curveBasis(n)}else if(g.interpolate=="cardinal"){p=pv.SvgScene.curveCardinal(m,g.tension);q=pv.SvgScene.curveCardinal(n,g.tension)}else{p=pv.SvgScene.curveMonotone(m);q=pv.SvgScene.curveMonotone(n)}return m[0].left+","+m[0].top+p+"L"+n[0].left+","+n[0].top+q}var f=b.$g.firstChild;if(!b.length)return f;var g=b[0];if(g.segmented)return this.areaSegment(b);if(!g.visible)return f;var h=g.fillStyle,i=g.strokeStyle;if(!h.opacity&&!i.opacity)re [...]
+[],k,l=0;l<b.length;l++){k=b[l];if(k.width||k.height){for(var s=l+1;s<b.length;s++){k=b[s];if(!k.width&&!k.height)break}l&&g.interpolate!="step-after"&&l--;s<b.length&&g.interpolate!="step-before"&&s++;j.push((s-l>2&&(g.interpolate=="basis"||g.interpolate=="cardinal"||g.interpolate=="monotone")?d:c)(l,s-1));l=s-1}}if(!j.length)return f;f=this.expect(f,"path",{"shape-rendering":g.antialias?null:"crispEdges","pointer-events":g.events,cursor:g.cursor,d:"M"+j.join("ZM")+"Z",fill:h.color,"fil [...]
+null,stroke:i.color,"stroke-opacity":i.opacity||null,"stroke-width":i.opacity?g.lineWidth/this.scale:null});return this.append(f,b,0)};
+pv.SvgScene.areaSegment=function(b){var c=b.$g.firstChild,d=b[0],f,g;if(d.interpolate=="basis"||d.interpolate=="cardinal"||d.interpolate=="monotone"){f=[];g=[];for(var h=0,i=b.length;h<i;h++){var j=b[i-h-1];f.push(b[h]);g.push({left:j.left+j.width,top:j.top+j.height})}if(d.interpolate=="basis"){f=this.curveBasisSegments(f);g=this.curveBasisSegments(g)}else if(d.interpolate=="cardinal"){f=this.curveCardinalSegments(f,d.tension);g=this.curveCardinalSegments(g,d.tension)}else{f=this.curveMo [...]
+g=this.curveMonotoneSegments(g)}}h=0;for(i=b.length-1;h<i;h++){d=b[h];var k=b[h+1];if(d.visible&&k.visible){var l=d.fillStyle,s=d.strokeStyle;if(l.opacity||s.opacity){if(f){j=f[h];k="L"+g[i-h-1].substr(1);j=j+k+"Z"}else{var p=d;j=k;switch(d.interpolate){case "step-before":p=k;break;case "step-after":j=d;break}j="M"+d.left+","+p.top+"L"+k.left+","+j.top+"L"+(k.left+k.width)+","+(j.top+j.height)+"L"+(d.left+d.width)+","+(p.top+p.height)+"Z"}c=this.expect(c,"path",{"shape-rendering":d.antia [...]
+"crispEdges","pointer-events":d.events,cursor:d.cursor,d:j,fill:l.color,"fill-opacity":l.opacity||null,stroke:s.color,"stroke-opacity":s.opacity||null,"stroke-width":s.opacity?d.lineWidth/this.scale:null});c=this.append(c,b,h)}}}return c};
+pv.SvgScene.bar=function(b){for(var c=b.$g.firstChild,d=0;d<b.length;d++){var f=b[d];if(f.visible){var g=f.fillStyle,h=f.strokeStyle;if(g.opacity||h.opacity){c=this.expect(c,"rect",{"shape-rendering":f.antialias?null:"crispEdges","pointer-events":f.events,cursor:f.cursor,x:f.left,y:f.top,width:Math.max(1.0E-10,f.width),height:Math.max(1.0E-10,f.height),fill:g.color,"fill-opacity":g.opacity||null,stroke:h.color,"stroke-opacity":h.opacity||null,"stroke-width":h.opacity?f.lineWidth/this.sca [...]
+c=this.append(c,b,d)}}}return c};
+pv.SvgScene.dot=function(b){for(var c=b.$g.firstChild,d=0;d<b.length;d++){var f=b[d];if(f.visible){var g=f.fillStyle,h=f.strokeStyle;if(g.opacity||h.opacity){var i=f.shapeRadius,j=null;switch(f.shape){case "cross":j="M"+-i+","+-i+"L"+i+","+i+"M"+i+","+-i+"L"+-i+","+i;break;case "triangle":j=i;var k=i*1.1547;j="M0,"+j+"L"+k+","+-j+" "+-k+","+-j+"Z";break;case "diamond":i*=Math.SQRT2;j="M0,"+-i+"L"+i+",0 0,"+i+" "+-i+",0Z";break;case "square":j="M"+-i+","+-i+"L"+i+","+-i+" "+i+","+i+" "+-i [...]
+break;case "tick":j="M0,0L0,"+-f.shapeSize;break;case "bar":j="M0,"+f.shapeSize/2+"L0,"+-(f.shapeSize/2);break}g={"shape-rendering":f.antialias?null:"crispEdges","pointer-events":f.events,cursor:f.cursor,fill:g.color,"fill-opacity":g.opacity||null,stroke:h.color,"stroke-opacity":h.opacity||null,"stroke-width":h.opacity?f.lineWidth/this.scale:null};if(j){g.transform="translate("+f.left+","+f.top+")";if(f.shapeAngle)g.transform+=" rotate("+180*f.shapeAngle/Math.PI+")";g.d=j;c=this.expect(c [...]
+f.left;g.cy=f.top;g.r=i;c=this.expect(c,"circle",g)}c=this.append(c,b,d)}}}return c};
+pv.SvgScene.image=function(b){for(var c=b.$g.firstChild,d=0;d<b.length;d++){var f=b[d];if(f.visible){c=this.fill(c,b,d);if(f.image){c=this.expect(c,"foreignObject",{cursor:f.cursor,x:f.left,y:f.top,width:f.width,height:f.height});var g=c.firstChild||c.appendChild(document.createElementNS(this.xhtml,"canvas"));g.$scene={scenes:b,index:d};g.style.width=f.width;g.style.height=f.height;g.width=f.imageWidth;g.height=f.imageHeight;g.getContext("2d").putImageData(f.image,0,0)}else{c=this.expect [...]
+{preserveAspectRatio:"none",cursor:f.cursor,x:f.left,y:f.top,width:f.width,height:f.height});c.setAttributeNS(this.xlink,"href",f.url)}c=this.append(c,b,d);c=this.stroke(c,b,d)}}return c};
+pv.SvgScene.label=function(b){for(var c=b.$g.firstChild,d=0;d<b.length;d++){var f=b[d];if(f.visible){var g=f.textStyle;if(g.opacity&&f.text){var h=0,i=0,j=0,k="start";switch(f.textBaseline){case "middle":j=".35em";break;case "top":j=".71em";i=f.textMargin;break;case "bottom":i="-"+f.textMargin;break}switch(f.textAlign){case "right":k="end";h="-"+f.textMargin;break;case "center":k="middle";break;case "left":h=f.textMargin;break}c=this.expect(c,"text",{"pointer-events":f.events,cursor:f.cu [...]
+y:i,dy:j,transform:"translate("+f.left+","+f.top+")"+(f.textAngle?" rotate("+180*f.textAngle/Math.PI+")":"")+(this.scale!=1?" scale("+1/this.scale+")":""),fill:g.color,"fill-opacity":g.opacity||null,"text-anchor":k},{font:f.font,"text-shadow":f.textShadow,"text-decoration":f.textDecoration});if(c.firstChild)c.firstChild.nodeValue=f.text;else c.appendChild(document.createTextNode(f.text));c=this.append(c,b,d)}}}return c};
+pv.SvgScene.line=function(b){var c=b.$g.firstChild;if(b.length<2)return c;var d=b[0];if(d.segmented)return this.lineSegment(b);if(!d.visible)return c;var f=d.fillStyle,g=d.strokeStyle;if(!f.opacity&&!g.opacity)return c;var h="M"+d.left+","+d.top;if(b.length>2&&(d.interpolate=="basis"||d.interpolate=="cardinal"||d.interpolate=="monotone"))switch(d.interpolate){case "basis":h+=this.curveBasis(b);break;case "cardinal":h+=this.curveCardinal(b,d.tension);break;case "monotone":h+=this.curveMon [...]
+break}else for(var i=1;i<b.length;i++)h+=this.pathSegment(b[i-1],b[i]);c=this.expect(c,"path",{"shape-rendering":d.antialias?null:"crispEdges","pointer-events":d.events,cursor:d.cursor,d:h,fill:f.color,"fill-opacity":f.opacity||null,stroke:g.color,"stroke-opacity":g.opacity||null,"stroke-width":g.opacity?d.lineWidth/this.scale:null,"stroke-linejoin":d.lineJoin});return this.append(c,b,0)};
+pv.SvgScene.lineSegment=function(b){var c=b.$g.firstChild,d=b[0],f;switch(d.interpolate){case "basis":f=this.curveBasisSegments(b);break;case "cardinal":f=this.curveCardinalSegments(b,d.tension);break;case "monotone":f=this.curveMonotoneSegments(b);break}d=0;for(var g=b.length-1;d<g;d++){var h=b[d],i=b[d+1];if(h.visible&&i.visible){var j=h.strokeStyle,k=pv.Color.transparent;if(j.opacity){if(h.interpolate=="linear"&&h.lineJoin=="miter"){k=j;j=pv.Color.transparent;i=this.pathJoin(b[d-1],h, [...]
+f?f[d]:"M"+h.left+","+h.top+this.pathSegment(h,i);c=this.expect(c,"path",{"shape-rendering":h.antialias?null:"crispEdges","pointer-events":h.events,cursor:h.cursor,d:i,fill:k.color,"fill-opacity":k.opacity||null,stroke:j.color,"stroke-opacity":j.opacity||null,"stroke-width":j.opacity?h.lineWidth/this.scale:null,"stroke-linejoin":h.lineJoin});c=this.append(c,b,d)}}}return c};
+pv.SvgScene.pathSegment=function(b,c){var d=1;switch(b.interpolate){case "polar-reverse":d=0;case "polar":var f=c.left-b.left,g=c.top-b.top;b=1-b.eccentricity;f=Math.sqrt(f*f+g*g)/(2*b);if(b<=0||b>1)break;return"A"+f+","+f+" 0 0,"+d+" "+c.left+","+c.top;case "step-before":return"V"+c.top+"H"+c.left;case "step-after":return"H"+c.left+"V"+c.top}return"L"+c.left+","+c.top};pv.SvgScene.lineIntersect=function(b,c,d,f){return b.plus(c.times(d.minus(b).dot(f.perp())/c.dot(f.perp())))};
+pv.SvgScene.pathJoin=function(b,c,d,f){var g=pv.vector(c.left,c.top);d=pv.vector(d.left,d.top);var h=d.minus(g),i=h.perp().norm(),j=i.times(c.lineWidth/(2*this.scale));c=g.plus(j);var k=d.plus(j),l=d.minus(j);j=g.minus(j);if(b&&b.visible){b=g.minus(b.left,b.top).perp().norm().plus(i);j=this.lineIntersect(g,b,j,h);c=this.lineIntersect(g,b,c,h)}if(f&&f.visible){f=pv.vector(f.left,f.top).minus(d).perp().norm().plus(i);l=this.lineIntersect(d,f,l,h);k=this.lineIntersect(d,f,k,h)}return"M"+c.x [...]
+"L"+k.x+","+k.y+" "+l.x+","+l.y+" "+j.x+","+j.y};
+pv.SvgScene.panel=function(b){for(var c=b.$g,d=c&&c.firstChild,f=0;f<b.length;f++){var g=b[f];if(g.visible){if(!b.parent){g.canvas.style.display="inline-block";if(c&&c.parentNode!=g.canvas)d=(c=g.canvas.firstChild)&&c.firstChild;if(!c){c=g.canvas.appendChild(this.create("svg"));c.setAttribute("font-size","10px");c.setAttribute("font-family","sans-serif");c.setAttribute("fill","none");c.setAttribute("stroke","none");c.setAttribute("stroke-width",1.5);for(var h=0;h<this.events.length;h++)c [...]
+this.dispatch,false);d=c.firstChild}b.$g=c;c.setAttribute("width",g.width+g.left+g.right);c.setAttribute("height",g.height+g.top+g.bottom)}if(g.overflow=="hidden"){h=pv.id().toString(36);var i=this.expect(d,"g",{"clip-path":"url(#"+h+")"});i.parentNode||c.appendChild(i);b.$g=c=i;d=i.firstChild;d=this.expect(d,"clipPath",{id:h});h=d.firstChild||d.appendChild(this.create("rect"));h.setAttribute("x",g.left);h.setAttribute("y",g.top);h.setAttribute("width",g.width);h.setAttribute("height",g. [...]
+c.appendChild(d);d=d.nextSibling}d=this.fill(d,b,f);var j=this.scale,k=g.transform,l=g.left+k.x,s=g.top+k.y;this.scale*=k.k;for(h=0;h<g.children.length;h++){g.children[h].$g=d=this.expect(d,"g",{transform:"translate("+l+","+s+")"+(k.k!=1?" scale("+k.k+")":"")});this.updateAll(g.children[h]);d.parentNode||c.appendChild(d);d=d.nextSibling}this.scale=j;d=this.stroke(d,b,f);if(g.overflow=="hidden"){b.$g=c=i.parentNode;d=i.nextSibling}}}return d};
+pv.SvgScene.fill=function(b,c,d){var f=c[d],g=f.fillStyle;if(g.opacity||f.events=="all"){b=this.expect(b,"rect",{"shape-rendering":f.antialias?null:"crispEdges","pointer-events":f.events,cursor:f.cursor,x:f.left,y:f.top,width:f.width,height:f.height,fill:g.color,"fill-opacity":g.opacity,stroke:null});b=this.append(b,c,d)}return b};
+pv.SvgScene.stroke=function(b,c,d){var f=c[d],g=f.strokeStyle;if(g.opacity||f.events=="all"){b=this.expect(b,"rect",{"shape-rendering":f.antialias?null:"crispEdges","pointer-events":f.events=="all"?"stroke":f.events,cursor:f.cursor,x:f.left,y:f.top,width:Math.max(1.0E-10,f.width),height:Math.max(1.0E-10,f.height),fill:null,stroke:g.color,"stroke-opacity":g.opacity,"stroke-width":f.lineWidth/this.scale});b=this.append(b,c,d)}return b};
+pv.SvgScene.rule=function(b){for(var c=b.$g.firstChild,d=0;d<b.length;d++){var f=b[d];if(f.visible){var g=f.strokeStyle;if(g.opacity){c=this.expect(c,"line",{"shape-rendering":f.antialias?null:"crispEdges","pointer-events":f.events,cursor:f.cursor,x1:f.left,y1:f.top,x2:f.left+f.width,y2:f.top+f.height,stroke:g.color,"stroke-opacity":g.opacity,"stroke-width":f.lineWidth/this.scale});c=this.append(c,b,d)}}}return c};
+pv.SvgScene.wedge=function(b){for(var c=b.$g.firstChild,d=0;d<b.length;d++){var f=b[d];if(f.visible){var g=f.fillStyle,h=f.strokeStyle;if(g.opacity||h.opacity){var i=f.innerRadius,j=f.outerRadius,k=Math.abs(f.angle);if(k>=2*Math.PI)i=i?"M0,"+j+"A"+j+","+j+" 0 1,1 0,"+-j+"A"+j+","+j+" 0 1,1 0,"+j+"M0,"+i+"A"+i+","+i+" 0 1,1 0,"+-i+"A"+i+","+i+" 0 1,1 0,"+i+"Z":"M0,"+j+"A"+j+","+j+" 0 1,1 0,"+-j+"A"+j+","+j+" 0 1,1 0,"+j+"Z";else{var l=Math.min(f.startAngle,f.endAngle),s=Math.max(f.startAn [...]
+p=Math.cos(l),q=Math.cos(s);l=Math.sin(l);s=Math.sin(s);i=i?"M"+j*p+","+j*l+"A"+j+","+j+" 0 "+(k<Math.PI?"0":"1")+",1 "+j*q+","+j*s+"L"+i*q+","+i*s+"A"+i+","+i+" 0 "+(k<Math.PI?"0":"1")+",0 "+i*p+","+i*l+"Z":"M"+j*p+","+j*l+"A"+j+","+j+" 0 "+(k<Math.PI?"0":"1")+",1 "+j*q+","+j*s+"L0,0Z"}c=this.expect(c,"path",{"shape-rendering":f.antialias?null:"crispEdges","pointer-events":f.events,cursor:f.cursor,transform:"translate("+f.left+","+f.top+")",d:i,fill:g.color,"fill-rule":"evenodd","fill-o [...]
+null,stroke:h.color,"stroke-opacity":h.opacity||null,"stroke-width":h.opacity?f.lineWidth/this.scale:null});c=this.append(c,b,d)}}}return c};pv.Mark=function(){this.$properties=[];this.$handlers={}};pv.Mark.prototype.properties={};pv.Mark.cast={};pv.Mark.prototype.property=function(b,c){if(!this.hasOwnProperty("properties"))this.properties=pv.extend(this.properties);this.properties[b]=true;pv.Mark.prototype.propertyMethod(b,false,pv.Mark.cast[b]=c);return this};
+pv.Mark.prototype.propertyMethod=function(b,c,d){d||(d=pv.Mark.cast[b]);this[b]=function(f){if(c&&this.scene){var g=this.scene.defs;if(arguments.length){g[b]={id:f==null?0:pv.id(),value:f!=null&&d?d(f):f};return this}return g[b]?g[b].value:null}if(arguments.length){g=!c<<1|typeof f=="function";this.propertyValue(b,g&1&&d?function(){var h=f.apply(this,arguments);return h!=null?d(h):null}:f!=null&&d?d(f):f).type=g;return this}return this.instance()[b]}};
+pv.Mark.prototype.propertyValue=function(b,c){var d=this.$properties;c={name:b,id:pv.id(),value:c};for(var f=0;f<d.length;f++)if(d[f].name==b){d.splice(f,1);break}d.push(c);return c};pv.Mark.prototype.property("data").property("visible",Boolean).property("left",Number).property("right",Number).property("top",Number).property("bottom",Number).property("cursor",String).property("title",String).property("reverse",Boolean).property("antialias",Boolean).property("events",String).property("id" [...]
+a=pv.Mark.prototype;a.childIndex=-1;a.index=-1;a.scale=1;a.defaults=(new pv.Mark).data(function(b){return[b]}).visible(true).antialias(true).events("painted");a.extend=function(b){this.proto=b;this.target=b.target;return this};a.add=function(b){return this.parent.add(b).extend(this)};a.def=function(b,c){this.propertyMethod(b,true);return this[b](arguments.length>1?c:null)};
+a.anchor=function(b){b||(b="center");return(new pv.Anchor(this)).name(b).data(function(){return this.scene.target.map(function(c){return c.data})}).visible(function(){return this.scene.target[this.index].visible}).id(function(){return this.scene.target[this.index].id}).left(function(){var c=this.scene.target[this.index],d=c.width||0;switch(this.name()){case "bottom":case "top":case "center":return c.left+d/2;case "left":return null}return c.left+d}).top(function(){var c=this.scene.target [...]
+d=c.height||0;switch(this.name()){case "left":case "right":case "center":return c.top+d/2;case "top":return null}return c.top+d}).right(function(){var c=this.scene.target[this.index];return this.name()=="left"?c.right+(c.width||0):null}).bottom(function(){var c=this.scene.target[this.index];return this.name()=="top"?c.bottom+(c.height||0):null}).textAlign(function(){switch(this.name()){case "bottom":case "top":case "center":return"center";case "right":return"right"}return"left"}).textBas [...]
+case "top":return"top"}return"bottom"})};a.anchorTarget=function(){return this.target};a.margin=function(b){return this.left(b).right(b).top(b).bottom(b)};a.instance=function(b){var c=this.scene||this.parent.instance(-1).children[this.childIndex],d=!arguments.length||this.hasOwnProperty("index")?this.index:b;return c[d<0?c.length-1:d]};
+a.instances=function(b){for(var c=this,d=[],f;!(f=c.scene);){b=b.parent;d.push({index:b.index,childIndex:c.childIndex});c=c.parent}for(;d.length;){b=d.pop();f=f[b.index].children[b.childIndex]}if(this.hasOwnProperty("index")){d=pv.extend(f[this.index]);d.right=d.top=d.left=d.bottom=0;return[d]}return f};a.first=function(){return this.scene[0]};a.last=function(){return this.scene[this.scene.length-1]};a.sibling=function(){return this.index==0?null:this.scene[this.index-1]};
+a.cousin=function(){var b=this.parent;return(b=b&&b.sibling())&&b.children?b.children[this.childIndex][this.index]:null};
+a.render=function(){function b(i,j,k){i.scale=k;if(j<g.length){f.unshift(null);if(i.hasOwnProperty("index"))c(i,j,k);else{for(var l=0,s=i.scene.length;l<s;l++){i.index=l;c(i,j,k)}delete i.index}f.shift()}else{i.build();pv.Scene.scale=k;pv.Scene.updateAll(i.scene)}delete i.scale}function c(i,j,k){var l=i.scene[i.index],s;if(l.visible){var p=g[j],q=i.children[p];for(s=0;s<p;s++)i.children[s].scene=l.children[s];f[0]=l.data;if(q.scene)b(q,j+1,k*l.transform.k);else{q.scene=l.children[p];b(q, [...]
+delete q.scene}for(s=0;s<p;s++)delete i.children[s].scene}}var d=this.parent,f=pv.Mark.stack;if(d&&!this.root.scene)this.root.render();else{for(var g=[],h=this;h.parent;h=h.parent)g.unshift(h.childIndex);for(this.bind();d&&!d.hasOwnProperty("index");)d=d.parent;this.context(d?d.scene:undefined,d?d.index:-1,function(){b(this.root,0,1)})}};pv.Mark.stack=[];a=pv.Mark.prototype;
+a.bind=function(){function b(j){do for(var k=j.$properties,l=k.length-1;l>=0;l--){var s=k[l];if(!(s.name in c)){c[s.name]=s;switch(s.name){case "data":f=s;break;case "visible":case "id":g.push(s);break;default:d[s.type].push(s);break}}}while(j=j.proto)}var c={},d=[[],[],[],[]],f,g=[];b(this);b(this.defaults);d[1].reverse();d[3].reverse();var h=this;do for(var i in h.properties)i in c||d[2].push(c[i]={name:i,type:2,value:null});while(h=h.proto);h=d[0].concat(d[1]);for(i=0;i<h.length;i++)t [...]
+true);this.binds={properties:c,data:f,defs:h,required:g,optional:pv.blend(d)}};
+a.build=function(){var b=this.scene,c=pv.Mark.stack;if(!b){b=this.scene=[];b.mark=this;b.type=this.type;b.childIndex=this.childIndex;if(this.parent){b.parent=this.parent.scene;b.parentIndex=this.parent.index}}if(this.target)b.target=this.target.instances(b);if(this.binds.defs.length){var d=b.defs;if(!d)b.defs=d={};for(var f=0;f<this.binds.defs.length;f++){var g=this.binds.defs[f],h=d[g.name];if(!h||g.id>h.id)d[g.name]={id:0,value:g.type&1?g.value.apply(this,c):g.value}}}d=this.binds.data [...]
+1?d.value.apply(this,c):d.value;c.unshift(null);b.length=d.length;for(f=0;f<d.length;f++){pv.Mark.prototype.index=this.index=f;(g=b[f])||(b[f]=g={});g.data=c[0]=d[f];this.buildInstance(g)}pv.Mark.prototype.index=-1;delete this.index;c.shift();return this};a.buildProperties=function(b,c){for(var d=0,f=c.length;d<f;d++){var g=c[d],h=g.value;switch(g.type){case 0:case 1:h=this.scene.defs[g.name].value;break;case 3:h=h.apply(this,pv.Mark.stack);break}b[g.name]=h}};
+a.buildInstance=function(b){this.buildProperties(b,this.binds.required);if(b.visible){this.buildProperties(b,this.binds.optional);this.buildImplied(b)}};
+a.buildImplied=function(b){var c=b.left,d=b.right,f=b.top,g=b.bottom,h=this.properties,i=h.width?b.width:0,j=h.height?b.height:0,k=this.parent?this.parent.width():i+c+d;if(i==null)i=k-(d=d||0)-(c=c||0);else if(d==null)if(c==null)c=d=(k-i)/2;else d=k-i-c;else if(c==null)c=k-i-d;k=this.parent?this.parent.height():j+f+g;if(j==null)j=k-(f=f||0)-(g=g||0);else if(g==null)g=f==null?(f=(k-j)/2):k-j-f;else if(f==null)f=k-j-g;b.left=c;b.right=d;b.top=f;b.bottom=g;if(h.width)b.width=i;if(h.height)b [...]
+if(h.textStyle&&!b.textStyle)b.textStyle=pv.Color.transparent;if(h.fillStyle&&!b.fillStyle)b.fillStyle=pv.Color.transparent;if(h.strokeStyle&&!b.strokeStyle)b.strokeStyle=pv.Color.transparent};
+a.mouse=function(){var b=pv.event.pageX||0,c=pv.event.pageY||0,d=this.root.canvas();do{b-=d.offsetLeft;c-=d.offsetTop}while(d=d.offsetParent);d=pv.Transform.identity;var f=this.properties.transform?this:this.parent,g=[];do g.push(f);while(f=f.parent);for(;f=g.pop();)d=d.translate(f.left(),f.top()).times(f.transform());d=d.invert();return pv.vector(b*d.k+d.x,c*d.k+d.y)};a.event=function(b,c){this.$handlers[b]=pv.functor(c);return this};
+a.context=function(b,c,d){function f(l,s){pv.Mark.scene=l;h.index=s;if(l){var p=l.mark,q=p,m=[];do{m.push(q);i.push(l[s].data);q.index=s;q.scene=l;s=l.parentIndex;l=l.parent}while(q=q.parent);l=m.length-1;for(s=1;l>0;l--){q=m[l];q.scale=s;s*=q.scene[q.index].transform.k}if(p.children){l=0;for(m=p.children.length;l<m;l++){q=p.children[l];q.scene=p.scene[p.index].children[l];q.scale=s}}}}function g(l){if(l){l=l.mark;var s;if(l.children)for(var p=0,q=l.children.length;p<q;p++){s=l.children[ [...]
+delete s.scale}s=l;do{i.pop();if(s.parent){delete s.scene;delete s.scale}delete s.index}while(s=s.parent)}}var h=pv.Mark.prototype,i=pv.Mark.stack,j=pv.Mark.scene,k=h.index;g(j,k);f(b,c);try{d.apply(this,i)}finally{g(b,c);f(j,k)}};pv.Mark.dispatch=function(b,c,d){var f=c.mark,g=c.parent,h=f.$handlers[b];if(!h)return g&&pv.Mark.dispatch(b,g,c.parentIndex);f.context(c,d,function(){(f=h.apply(f,pv.Mark.stack))&&f.render&&f.render()});return true};pv.Mark.prototype.transition=function(){retu [...]
+pv.Mark.prototype.on=function(b){return this["$"+b]=new pv.Transient(this)};pv.Anchor=function(b){pv.Mark.call(this);this.target=b;this.parent=b.parent};pv.Anchor.prototype=pv.extend(pv.Mark).property("name",String);pv.Anchor.prototype.extend=function(b){this.proto=b;return this};pv.Area=function(){pv.Mark.call(this)};
+pv.Area.prototype=pv.extend(pv.Mark).property("width",Number).property("height",Number).property("lineWidth",Number).property("strokeStyle",pv.color).property("fillStyle",pv.color).property("segmented",Boolean).property("interpolate",String).property("tension",Number);pv.Area.prototype.type="area";pv.Area.prototype.defaults=(new pv.Area).extend(pv.Mark.prototype.defaults).lineWidth(1.5).fillStyle(pv.Colors.category20().by(pv.parent)).interpolate("linear").tension(0.7);
+pv.Area.prototype.buildImplied=function(b){if(b.height==null)b.height=0;if(b.width==null)b.width=0;pv.Mark.prototype.buildImplied.call(this,b)};pv.Area.fixed={lineWidth:1,lineJoin:1,strokeStyle:1,fillStyle:1,segmented:1,interpolate:1,tension:1};
+pv.Area.prototype.bind=function(){pv.Mark.prototype.bind.call(this);var b=this.binds,c=b.required;b=b.optional;for(var d=0,f=b.length;d<f;d++){var g=b[d];g.fixed=g.name in pv.Area.fixed;if(g.name=="segmented"){c.push(g);b.splice(d,1);d--;f--}}this.binds.$required=c;this.binds.$optional=b};
+pv.Area.prototype.buildInstance=function(b){var c=this.binds;if(this.index){var d=c.fixed;if(!d){d=c.fixed=[];function f(i){return!i.fixed||(d.push(i),false)}c.required=c.required.filter(f);if(!this.scene[0].segmented)c.optional=c.optional.filter(f)}c=0;for(var g=d.length;c<g;c++){var h=d[c].name;b[h]=this.scene[0][h]}}else{c.required=c.$required;c.optional=c.$optional;c.fixed=null}pv.Mark.prototype.buildInstance.call(this,b)};
+pv.Area.prototype.anchor=function(b){return pv.Mark.prototype.anchor.call(this,b).interpolate(function(){return this.scene.target[this.index].interpolate}).eccentricity(function(){return this.scene.target[this.index].eccentricity}).tension(function(){return this.scene.target[this.index].tension})};pv.Bar=function(){pv.Mark.call(this)};
+pv.Bar.prototype=pv.extend(pv.Mark).property("width",Number).property("height",Number).property("lineWidth",Number).property("strokeStyle",pv.color).property("fillStyle",pv.color);pv.Bar.prototype.type="bar";pv.Bar.prototype.defaults=(new pv.Bar).extend(pv.Mark.prototype.defaults).lineWidth(1.5).fillStyle(pv.Colors.category20().by(pv.parent));pv.Dot=function(){pv.Mark.call(this)};
+pv.Dot.prototype=pv.extend(pv.Mark).property("shape",String).property("shapeAngle",Number).property("shapeRadius",Number).property("shapeSize",Number).property("lineWidth",Number).property("strokeStyle",pv.color).property("fillStyle",pv.color);pv.Dot.prototype.type="dot";pv.Dot.prototype.defaults=(new pv.Dot).extend(pv.Mark.prototype.defaults).shape("circle").lineWidth(1.5).strokeStyle(pv.Colors.category10().by(pv.parent));
+pv.Dot.prototype.anchor=function(b){return pv.Mark.prototype.anchor.call(this,b).left(function(){var c=this.scene.target[this.index];switch(this.name()){case "bottom":case "top":case "center":return c.left;case "left":return null}return c.left+c.shapeRadius}).right(function(){var c=this.scene.target[this.index];return this.name()=="left"?c.right+c.shapeRadius:null}).top(function(){var c=this.scene.target[this.index];switch(this.name()){case "left":case "right":case "center":return c.top; [...]
+c.shapeRadius}).bottom(function(){var c=this.scene.target[this.index];return this.name()=="top"?c.bottom+c.shapeRadius:null}).textAlign(function(){switch(this.name()){case "left":return"right";case "bottom":case "top":case "center":return"center"}return"left"}).textBaseline(function(){switch(this.name()){case "right":case "left":case "center":return"middle";case "bottom":return"top"}return"bottom"})};
+pv.Dot.prototype.buildImplied=function(b){var c=b.shapeRadius,d=b.shapeSize;if(c==null)if(d==null){b.shapeSize=20.25;b.shapeRadius=4.5}else b.shapeRadius=Math.sqrt(d);else if(d==null)b.shapeSize=c*c;pv.Mark.prototype.buildImplied.call(this,b)};pv.Label=function(){pv.Mark.call(this)};
+pv.Label.prototype=pv.extend(pv.Mark).property("text",String).property("font",String).property("textAngle",Number).property("textStyle",pv.color).property("textAlign",String).property("textBaseline",String).property("textMargin",Number).property("textDecoration",String).property("textShadow",String);pv.Label.prototype.type="label";pv.Label.prototype.defaults=(new pv.Label).extend(pv.Mark.prototype.defaults).events("none").text(pv.identity).font("10px sans-serif").textAngle(0).textStyle(" [...]
+pv.Line=function(){pv.Mark.call(this)};pv.Line.prototype=pv.extend(pv.Mark).property("lineWidth",Number).property("lineJoin",String).property("strokeStyle",pv.color).property("fillStyle",pv.color).property("segmented",Boolean).property("interpolate",String).property("eccentricity",Number).property("tension",Number);a=pv.Line.prototype;a.type="line";a.defaults=(new pv.Line).extend(pv.Mark.prototype.defaults).lineJoin("miter").lineWidth(1.5).strokeStyle(pv.Colors.category10().by(pv.parent) [...]
+a.bind=pv.Area.prototype.bind;a.buildInstance=pv.Area.prototype.buildInstance;a.anchor=function(b){return pv.Area.prototype.anchor.call(this,b).textAlign(function(){switch(this.name()){case "left":return"right";case "bottom":case "top":case "center":return"center";case "right":return"left"}}).textBaseline(function(){switch(this.name()){case "right":case "left":case "center":return"middle";case "top":return"bottom";case "bottom":return"top"}})};pv.Rule=function(){pv.Mark.call(this)};
+pv.Rule.prototype=pv.extend(pv.Mark).property("width",Number).property("height",Number).property("lineWidth",Number).property("strokeStyle",pv.color);pv.Rule.prototype.type="rule";pv.Rule.prototype.defaults=(new pv.Rule).extend(pv.Mark.prototype.defaults).lineWidth(1).strokeStyle("black").antialias(false);pv.Rule.prototype.anchor=pv.Line.prototype.anchor;
+pv.Rule.prototype.buildImplied=function(b){var c=b.left,d=b.right;if(b.width!=null||c==null&&d==null||d!=null&&c!=null)b.height=0;else b.width=0;pv.Mark.prototype.buildImplied.call(this,b)};pv.Panel=function(){pv.Bar.call(this);this.children=[];this.root=this;this.$dom=pv.$&&pv.$.s};pv.Panel.prototype=pv.extend(pv.Bar).property("transform").property("overflow",String).property("canvas",function(b){return typeof b=="string"?document.getElementById(b):b});a=pv.Panel.prototype;a.type="panel";
+a.defaults=(new pv.Panel).extend(pv.Bar.prototype.defaults).fillStyle(null).overflow("visible");a.anchor=function(b){b=pv.Bar.prototype.anchor.call(this,b);b.parent=this;return b};a.add=function(b){b=new b;b.parent=this;b.root=this.root;b.childIndex=this.children.length;this.children.push(b);return b};a.bind=function(){pv.Mark.prototype.bind.call(this);for(var b=0;b<this.children.length;b++)this.children[b].bind()};
+a.buildInstance=function(b){pv.Bar.prototype.buildInstance.call(this,b);if(b.visible){if(!b.children)b.children=[];var c=this.scale*b.transform.k,d,f=this.children.length;pv.Mark.prototype.index=-1;for(var g=0;g<f;g++){d=this.children[g];d.scene=b.children[g];d.scale=c;d.build()}for(g=0;g<f;g++){d=this.children[g];b.children[g]=d.scene;delete d.scene;delete d.scale}b.children.length=f}};
+a.buildImplied=function(b){if(!this.parent){var c=b.canvas;if(c){if(c.$panel!=this)for(c.$panel=this;c.lastChild;)c.removeChild(c.lastChild);var d;if(b.width==null){d=parseFloat(pv.css(c,"width"));b.width=d-b.left-b.right}if(b.height==null){d=parseFloat(pv.css(c,"height"));b.height=d-b.top-b.bottom}}else{d=this.$canvas||(this.$canvas=[]);if(!(c=d[this.index])){c=d[this.index]=document.createElement("span");if(this.$dom)this.$dom.parentNode.insertBefore(c,this.$dom);else{for(d=document.bo [...]
+d.lastChild.tagName;)d=d.lastChild;if(d!=document.body)d=d.parentNode;d.appendChild(c)}}}b.canvas=c}if(!b.transform)b.transform=pv.Transform.identity;pv.Mark.prototype.buildImplied.call(this,b)};pv.Image=function(){pv.Bar.call(this)};pv.Image.prototype=pv.extend(pv.Bar).property("url",String).property("imageWidth",Number).property("imageHeight",Number);a=pv.Image.prototype;a.type="image";a.defaults=(new pv.Image).extend(pv.Bar.prototype.defaults).fillStyle(null);
+a.image=function(b){this.$image=function(){var c=b.apply(this,arguments);return c==null?pv.Color.transparent:typeof c=="string"?pv.color(c):c};return this};a.bind=function(){pv.Bar.prototype.bind.call(this);var b=this.binds,c=this;do b.image=c.$image;while(!b.image&&(c=c.proto))};
+a.buildImplied=function(b){pv.Bar.prototype.buildImplied.call(this,b);if(b.visible){if(b.imageWidth==null)b.imageWidth=b.width;if(b.imageHeight==null)b.imageHeight=b.height;if(b.url==null&&this.binds.image){var c=this.$canvas||(this.$canvas=document.createElement("canvas")),d=c.getContext("2d"),f=b.imageWidth,g=b.imageHeight,h=pv.Mark.stack;c.width=f;c.height=g;b=(b.image=d.createImageData(f,g)).data;h.unshift(null,null);for(d=c=0;c<g;c++){h[1]=c;for(var i=0;i<f;i++){h[0]=i;var j=this.bi [...]
+h);b[d++]=j.r;b[d++]=j.g;b[d++]=j.b;b[d++]=255*j.a}}h.splice(0,2)}}};pv.Wedge=function(){pv.Mark.call(this)};pv.Wedge.prototype=pv.extend(pv.Mark).property("startAngle",Number).property("endAngle",Number).property("angle",Number).property("innerRadius",Number).property("outerRadius",Number).property("lineWidth",Number).property("strokeStyle",pv.color).property("fillStyle",pv.color);a=pv.Wedge.prototype;a.type="wedge";
+a.defaults=(new pv.Wedge).extend(pv.Mark.prototype.defaults).startAngle(function(){var b=this.sibling();return b?b.endAngle:-Math.PI/2}).innerRadius(0).lineWidth(1.5).strokeStyle(null).fillStyle(pv.Colors.category20().by(pv.index));a.midRadius=function(){return(this.innerRadius()+this.outerRadius())/2};a.midAngle=function(){return(this.startAngle()+this.endAngle())/2};
+a.anchor=function(b){function c(g){return g.innerRadius||g.angle<2*Math.PI}function d(g){return(g.innerRadius+g.outerRadius)/2}function f(g){return(g.startAngle+g.endAngle)/2}return pv.Mark.prototype.anchor.call(this,b).left(function(){var g=this.scene.target[this.index];if(c(g))switch(this.name()){case "outer":return g.left+g.outerRadius*Math.cos(f(g));case "inner":return g.left+g.innerRadius*Math.cos(f(g));case "start":return g.left+d(g)*Math.cos(g.startAngle);case "center":return g.le [...]
+case "end":return g.left+d(g)*Math.cos(g.endAngle)}return g.left}).top(function(){var g=this.scene.target[this.index];if(c(g))switch(this.name()){case "outer":return g.top+g.outerRadius*Math.sin(f(g));case "inner":return g.top+g.innerRadius*Math.sin(f(g));case "start":return g.top+d(g)*Math.sin(g.startAngle);case "center":return g.top+d(g)*Math.sin(f(g));case "end":return g.top+d(g)*Math.sin(g.endAngle)}return g.top}).textAlign(function(){var g=this.scene.target[this.index];if(c(g))switc [...]
+"right":"left";case "inner":return pv.Wedge.upright(f(g))?"left":"right"}return"center"}).textBaseline(function(){var g=this.scene.target[this.index];if(c(g))switch(this.name()){case "start":return pv.Wedge.upright(g.startAngle)?"top":"bottom";case "end":return pv.Wedge.upright(g.endAngle)?"bottom":"top"}return"middle"}).textAngle(function(){var g=this.scene.target[this.index],h=0;if(c(g))switch(this.name()){case "center":case "inner":case "outer":h=f(g);break;case "start":h=g.startAngle [...]
+g.endAngle;break}return pv.Wedge.upright(h)?h:h+Math.PI})};pv.Wedge.upright=function(b){b%=2*Math.PI;b=b<0?2*Math.PI+b:b;return b<Math.PI/2||b>=3*Math.PI/2};pv.Wedge.prototype.buildImplied=function(b){if(b.angle==null)b.angle=b.endAngle-b.startAngle;else if(b.endAngle==null)b.endAngle=b.startAngle+b.angle;pv.Mark.prototype.buildImplied.call(this,b)};
+pv.Ease=function(){function b(n){return function(r){return 1-n(1-r)}}function c(n){return function(r){return 0.5*(r<0.5?n(2*r):2-n(2-2*r))}}function d(n){return function(r){return r<0?0:r>1?1:Math.pow(r,n)}}function f(n){return 1-Math.cos(n*Math.PI/2)}function g(n){return n?Math.pow(2,10*(n-1))-0.0010:0}function h(n){return-(Math.sqrt(1-n*n)-1)}function i(n,r){var t;r||(r=0.45);if(!n||n<1){n=1;t=r/4}else t=r/(2*Math.PI)*Math.asin(1/n);return function(x){return x<=0||x>=1?x:-(n*Math.pow(2 [...]
+Math.sin((x-t)*2*Math.PI/r))}}function j(n){n||(n=1.70158);return function(r){return r*r*((n+1)*r-n)}}function k(n){return n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+0.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+0.9375:7.5625*(n-=2.625/2.75)*n+0.984375}var l=d(2),s=d(3),p=i(),q=j(),m={linear:pv.identity,"quad-in":l,"quad-out":b(l),"quad-in-out":c(l),"quad-out-in":c(b(l)),"cubic-in":s,"cubic-out":b(s),"cubic-in-out":c(s),"cubic-out-in":c(b(s)),"sin-in":f,"sin-out":b(f),"sin-in-out":c(f [...]
+"exp-in":g,"exp-out":b(g),"exp-in-out":c(g),"exp-out-in":c(b(g)),"circle-in":h,"circle-out":b(h),"circle-in-out":c(h),"circle-out-in":c(b(h)),"elastic-in":p,"elastic-out":b(p),"elastic-in-out":c(p),"elastic-out-in":c(b(p)),"back-in":q,"back-out":b(q),"back-in-out":c(q),"back-out-in":c(b(q)),"bounce-in":k,"bounce-out":b(k),"bounce-in-out":c(k),"bounce-out-in":c(b(k))};pv.ease=function(n){return m[n]};return{reverse:b,reflect:c,linear:function(){return pv.identity},sin:function(){return f} [...]
+circle:function(){return h},elastic:i,back:j,bounce:k,poly:d}}();
+pv.Transition=function(b){function c(m){for(var n={},r=0;r<m.length;r++){var t=m[r];if(t.id)n[t.id]=t}return n}function d(m,n,r,t){if(n in p)var x=pv.Scale.interpolator(r[n],t[n]),u=function(o){r[n]=x(o)};else u=function(o){if(o>0.5)r[n]=t[n]};u.next=m.head;m.head=u}function f(m,n,r){for(var t in n)t!="children"&&n[t]!=r[t]&&d(m,t,n,r);if(n.children)for(t=0;t<n.children.length;t++)g(m,n.children[t],r.children[t])}function g(m,n,r){for(var t=n.mark,x=c(n),u=c(r),o=0;o<n.length;o++){var v= [...]
+u[v.id]:r[o];v.index=o;if(v.visible){if(!(w&&w.visible)){var y=h(n,o,t.$exit,r);v.transition=w?2:(r.push(y),1);w=y}f(m,v,w)}}for(o=0;o<r.length;o++){w=r[o];v=w.id?x[w.id]:n[o];if(!(v&&v.visible)&&w.visible){y=h(r,o,t.$enter,n);if(v)n[v.index]=y;else n.push(y);f(m,y,w)}}}function h(m,n,r,t){var x=pv.extend(m[n]),u=m.mark,o=u.root.scene,v=(r||q).$properties,w;if(t.target&&(w=t.target[t.length])){m=pv.extend(m);m.target=pv.extend(t.target);m.target[n]=w}var y={};for(r=0;r<v.length;r++)y[v[r [...]
+v=u.binds.optional.filter(function(z){return!(z.name in y)}).concat(v);u.context(m,n,function(){this.buildProperties(x,v);this.buildImplied(x)});u.root.scene=o;return x}function i(m){for(var n=0,r=0;n<m.length;n++){var t=m[n];if(t.transition!=1){m[r++]=t;if(t.transition==2)t.visible=false;t.children&&t.children.forEach(i)}}m.length=r}var j=this,k=pv.ease("cubic-in-out"),l=250,s,p={top:1,left:1,right:1,bottom:1,width:1,height:1,innerRadius:1,outerRadius:1,radius:1,startAngle:1,endAngle:1, [...]
+strokeStyle:1,lineWidth:1,eccentricity:1,tension:1,textAngle:1,textStyle:1,textMargin:1},q=new pv.Transient;j.ease=function(m){return arguments.length?(k=typeof m=="function"?m:pv.ease(m),j):k};j.duration=function(m){return arguments.length?(l=Number(m),j):l};j.start=function(){b.parent&&fail();b.$transition&&b.$transition.stop();b.$transition=j;var m=pv.Mark.prototype.index,n=b.scene,r;b.scene=null;b.bind();b.build();r=b.scene;b.scene=n;pv.Mark.prototype.index=m;var t=Date.now(),x={};g( [...]
+setInterval(function(){for(var u=Math.max(0,Math.min(1,(Date.now()-t)/l)),o=k(u),v=x.head;v;v=v.next)v(o);if(u==1){i(b.scene);j.stop()}pv.Scene.updateAll(n)},24)};j.stop=function(){clearInterval(s)}};pv.Transient=function(b){pv.Mark.call(this);this.fillStyle(null).strokeStyle(null).textStyle(null);this.on=function(c){return b.on(c)}};pv.Transient.prototype=pv.extend(pv.Mark);pv.simulation=function(b){return new pv.Simulation(b)};pv.Simulation=function(b){for(var c=0;c<b.length;c++)this.p [...]
+a=pv.Simulation.prototype;a.particle=function(b){b.next=this.particles;if(isNaN(b.px))b.px=b.x;if(isNaN(b.py))b.py=b.y;if(isNaN(b.fx))b.fx=0;if(isNaN(b.fy))b.fy=0;this.particles=b;return this};a.force=function(b){b.next=this.forces;this.forces=b;return this};a.constraint=function(b){b.next=this.constraints;this.constraints=b;return this};
+a.stabilize=function(b){var c;arguments.length||(b=3);for(var d=0;d<b;d++){var f=new pv.Quadtree(this.particles);for(c=this.constraints;c;c=c.next)c.apply(this.particles,f)}for(c=this.particles;c;c=c.next){c.px=c.x;c.py=c.y}return this};
+a.step=function(){var b;for(b=this.particles;b;b=b.next){var c=b.px,d=b.py;b.px=b.x;b.py=b.y;b.x+=b.vx=b.x-c+b.fx;b.y+=b.vy=b.y-d+b.fy}c=new pv.Quadtree(this.particles);for(b=this.constraints;b;b=b.next)b.apply(this.particles,c);for(b=this.particles;b;b=b.next)b.fx=b.fy=0;for(b=this.forces;b;b=b.next)b.apply(this.particles,c)};
+pv.Quadtree=function(b){function c(l,s,p,q,m,n){if(!(isNaN(s.x)||isNaN(s.y)))if(l.leaf)if(l.p){if(!(Math.abs(l.p.x-s.x)+Math.abs(l.p.y-s.y)<0.01)){var r=l.p;l.p=null;d(l,r,p,q,m,n)}d(l,s,p,q,m,n)}else l.p=s;else d(l,s,p,q,m,n)}function d(l,s,p,q,m,n){var r=(p+m)*0.5,t=(q+n)*0.5,x=s.x>=r,u=s.y>=t;l.leaf=false;switch((u<<1)+x){case 0:l=l.c1||(l.c1=new pv.Quadtree.Node);break;case 1:l=l.c2||(l.c2=new pv.Quadtree.Node);break;case 2:l=l.c3||(l.c3=new pv.Quadtree.Node);break;case 3:l=l.c4||(l. [...]
+break}if(x)p=r;else m=r;if(u)q=t;else n=t;c(l,s,p,q,m,n)}var f,g=Number.POSITIVE_INFINITY,h=g,i=Number.NEGATIVE_INFINITY,j=i;for(f=b;f;f=f.next){if(f.x<g)g=f.x;if(f.y<h)h=f.y;if(f.x>i)i=f.x;if(f.y>j)j=f.y}f=i-g;var k=j-h;if(f>k)j=h+f;else i=g+k;this.xMin=g;this.yMin=h;this.xMax=i;this.yMax=j;this.root=new pv.Quadtree.Node;for(f=b;f;f=f.next)c(this.root,f,g,h,i,j)};pv.Quadtree.Node=function(){this.leaf=true;this.p=this.c4=this.c3=this.c2=this.c1=null};pv.Force={};
+pv.Force.charge=function(b){function c(l){function s(m){c(m);l.cn+=m.cn;p+=m.cn*m.cx;q+=m.cn*m.cy}var p=0,q=0;l.cn=0;if(!l.leaf){l.c1&&s(l.c1);l.c2&&s(l.c2);l.c3&&s(l.c3);l.c4&&s(l.c4)}if(l.p){l.cn+=b;p+=b*l.p.x;q+=b*l.p.y}l.cx=p/l.cn;l.cy=q/l.cn}function d(l,s,p,q,m,n){var r=l.cx-s.x,t=l.cy-s.y,x=1/Math.sqrt(r*r+t*t);if(l.leaf&&l.p!=s||(m-p)*x<j){if(!(x<i)){if(x>g)x=g;l=l.cn*x*x*x;r=r*l;t=t*l;s.fx+=r;s.fy+=t}}else if(!l.leaf){var u=(p+m)*0.5,o=(q+n)*0.5;l.c1&&d(l.c1,s,p,q,u,o);l.c2&&d(l [...]
+m,o);l.c3&&d(l.c3,s,p,o,u,n);l.c4&&d(l.c4,s,u,o,m,n);if(!(x<i)){if(x>g)x=g;if(l.p&&l.p!=s){l=b*x*x*x;r=r*l;t=t*l;s.fx+=r;s.fy+=t}}}}var f=2,g=1/f,h=500,i=1/h,j=0.9,k={};arguments.length||(b=-40);k.constant=function(l){if(arguments.length){b=Number(l);return k}return b};k.domain=function(l,s){if(arguments.length){f=Number(l);g=1/f;h=Number(s);i=1/h;return k}return[f,h]};k.theta=function(l){if(arguments.length){j=Number(l);return k}return j};k.apply=function(l,s){c(s.root);for(l=l;l;l=l.ne [...]
+l,s.xMin,s.yMin,s.xMax,s.yMax)};return k};pv.Force.drag=function(b){var c={};arguments.length||(b=0.1);c.constant=function(d){if(arguments.length){b=d;return c}return b};c.apply=function(d){if(b)for(d=d;d;d=d.next){d.fx-=b*d.vx;d.fy-=b*d.vy}};return c};
+pv.Force.spring=function(b){var c=0.1,d=20,f,g,h={};arguments.length||(b=0.1);h.links=function(i){if(arguments.length){f=i;g=i.map(function(j){return 1/Math.sqrt(Math.max(j.sourceNode.linkDegree,j.targetNode.linkDegree))});return h}return f};h.constant=function(i){if(arguments.length){b=Number(i);return h}return b};h.damping=function(i){if(arguments.length){c=Number(i);return h}return c};h.length=function(i){if(arguments.length){d=Number(i);return h}return d};h.apply=function(){for(var i [...]
+f[i].sourceNode,k=f[i].targetNode,l=j.x-k.x,s=j.y-k.y,p=Math.sqrt(l*l+s*s),q=p?1/p:1;q=(b*g[i]*(p-d)+c*g[i]*(l*(j.vx-k.vx)+s*(j.vy-k.vy))*q)*q;l=-q*(p?l:0.01*(0.5-Math.random()));s=-q*(p?s:0.01*(0.5-Math.random()));j.fx+=l;j.fy+=s;k.fx-=l;k.fy-=s}};return h};pv.Constraint={};
+pv.Constraint.collision=function(b){function c(l,s,p,q,m,n){if(!l.leaf){var r=(p+m)*0.5,t=(q+n)*0.5,x=t<j,u=r>g,o=r<i;if(t>h){l.c1&&u&&c(l.c1,s,p,q,r,t);l.c2&&o&&c(l.c2,s,r,q,m,t)}if(x){l.c3&&u&&c(l.c3,s,p,t,r,n);l.c4&&o&&c(l.c4,s,r,t,m,n)}}if(l.p&&l.p!=s){p=s.x-l.p.x;q=s.y-l.p.y;m=Math.sqrt(p*p+q*q);n=f+b(l.p);if(m<n){m=(m-n)/m*0.5;p*=m;q*=m;s.x-=p;s.y-=q;l.p.x+=p;l.p.y+=q}}}var d=1,f,g,h,i,j,k={};arguments.length||(f=10);k.repeat=function(l){if(arguments.length){d=Number(l);return k}re [...]
+function(l,s){var p,q,m=-Infinity;for(p=l;p;p=p.next){q=b(p);if(q>m)m=q}for(var n=0;n<d;n++)for(p=l;p;p=p.next){q=(f=b(p))+m;g=p.x-q;i=p.x+q;h=p.y-q;j=p.y+q;c(s.root,p,s.xMin,s.yMin,s.xMax,s.yMax)}};return k};pv.Constraint.position=function(b){var c=1,d={};arguments.length||(b=function(f){return f.fix});d.alpha=function(f){if(arguments.length){c=Number(f);return d}return c};d.apply=function(f){for(f=f;f;f=f.next){var g=b(f);if(g){f.x+=(g.x-f.x)*c;f.y+=(g.y-f.y)*c;f.fx=f.fy=f.vx=f.vy=0}}} [...]
+pv.Constraint.bound=function(){var b={},c,d;b.x=function(f,g){if(arguments.length){c={min:Math.min(f,g),max:Math.max(f,g)};return this}return c};b.y=function(f,g){if(arguments.length){d={min:Math.min(f,g),max:Math.max(f,g)};return this}return d};b.apply=function(f){if(c)for(var g=f;g;g=g.next)g.x=g.x<c.min?c.min:g.x>c.max?c.max:g.x;if(d)for(g=f;g;g=g.next)g.y=g.y<d.min?d.min:g.y>d.max?d.max:g.y};return b};pv.Layout=function(){pv.Panel.call(this)};pv.Layout.prototype=pv.extend(pv.Panel);
+pv.Layout.prototype.property=function(b,c){if(!this.hasOwnProperty("properties"))this.properties=pv.extend(this.properties);this.properties[b]=true;this.propertyMethod(b,false,pv.Mark.cast[b]=c);return this};
+pv.Layout.Network=function(){pv.Layout.call(this);var b=this;this.$id=pv.id();(this.node=(new pv.Mark).data(function(){return b.nodes()}).strokeStyle("#1f77b4").fillStyle("#fff").left(function(c){return c.x}).top(function(c){return c.y})).parent=this;this.link=(new pv.Mark).extend(this.node).data(function(c){return[c.sourceNode,c.targetNode]}).fillStyle(null).lineWidth(function(c,d){return d.linkValue*1.5}).strokeStyle("rgba(0,0,0,.2)");this.link.add=function(c){return b.add(pv.Panel).da [...]
+(this.label=(new pv.Mark).extend(this.node).textMargin(7).textBaseline("middle").text(function(c){return c.nodeName||c.nodeValue}).textAngle(function(c){c=c.midAngle;return pv.Wedge.upright(c)?c:c+Math.PI}).textAlign(function(c){return pv.Wedge.upright(c.midAngle)?"left":"right"})).parent=this};
+pv.Layout.Network.prototype=pv.extend(pv.Layout).property("nodes",function(b){return b.map(function(c,d){if(typeof c!="object")c={nodeValue:c};c.index=d;return c})}).property("links",function(b){return b.map(function(c){if(isNaN(c.linkValue))c.linkValue=isNaN(c.value)?1:c.value;return c})});pv.Layout.Network.prototype.reset=function(){this.$id=pv.id();return this};pv.Layout.Network.prototype.buildProperties=function(b,c){if((b.$id||0)<this.$id)pv.Layout.prototype.buildProperties.call(thi [...]
+pv.Layout.Network.prototype.buildImplied=function(b){pv.Layout.prototype.buildImplied.call(this,b);if(b.$id>=this.$id)return true;b.$id=this.$id;b.nodes.forEach(function(c){c.linkDegree=0});b.links.forEach(function(c){var d=c.linkValue;(c.sourceNode||(c.sourceNode=b.nodes[c.source])).linkDegree+=d;(c.targetNode||(c.targetNode=b.nodes[c.target])).linkDegree+=d})};pv.Layout.Hierarchy=function(){pv.Layout.Network.call(this);this.link.strokeStyle("#ccc")};pv.Layout.Hierarchy.prototype=pv.ext [...]
+pv.Layout.Hierarchy.prototype.buildImplied=function(b){if(!b.links)b.links=pv.Layout.Hierarchy.links.call(this);pv.Layout.Network.prototype.buildImplied.call(this,b)};pv.Layout.Hierarchy.links=function(){return this.nodes().filter(function(b){return b.parentNode}).map(function(b){return{sourceNode:b,targetNode:b.parentNode,linkValue:1}})};
+pv.Layout.Hierarchy.NodeLink={buildImplied:function(b){function c(m){return m.parentNode?m.depth*(p-s)+s:0}function d(m){return m.parentNode?(m.breadth-0.25)*2*Math.PI:0}function f(m){switch(i){case "left":return m.depth*k;case "right":return k-m.depth*k;case "top":return m.breadth*k;case "bottom":return k-m.breadth*k;case "radial":return k/2+c(m)*Math.cos(m.midAngle)}}function g(m){switch(i){case "left":return m.breadth*l;case "right":return l-m.breadth*l;case "top":return m.depth*l;cas [...]
+m.depth*l;case "radial":return l/2+c(m)*Math.sin(m.midAngle)}}var h=b.nodes,i=b.orient,j=/^(top|bottom)$/.test(i),k=b.width,l=b.height;if(i=="radial"){var s=b.innerRadius,p=b.outerRadius;if(s==null)s=0;if(p==null)p=Math.min(k,l)/2}for(b=0;b<h.length;b++){var q=h[b];q.midAngle=i=="radial"?d(q):j?Math.PI/2:0;q.x=f(q);q.y=g(q);if(q.firstChild)q.midAngle+=Math.PI}}};
+pv.Layout.Hierarchy.Fill={constructor:function(){this.node.strokeStyle("#fff").fillStyle("#ccc").width(function(b){return b.dx}).height(function(b){return b.dy}).innerRadius(function(b){return b.innerRadius}).outerRadius(function(b){return b.outerRadius}).startAngle(function(b){return b.startAngle}).angle(function(b){return b.angle});this.label.textAlign("center").left(function(b){return b.x+b.dx/2}).top(function(b){return b.y+b.dy/2});delete this.link},buildImplied:function(b){function  [...]
+v)/(1+v)}function d(o){switch(p){case "left":return c(o.minDepth,r)*m;case "right":return(1-c(o.maxDepth,r))*m;case "top":return o.minBreadth*m;case "bottom":return(1-o.maxBreadth)*m;case "radial":return m/2}}function f(o){switch(p){case "left":return o.minBreadth*n;case "right":return(1-o.maxBreadth)*n;case "top":return c(o.minDepth,r)*n;case "bottom":return(1-c(o.maxDepth,r))*n;case "radial":return n/2}}function g(o){switch(p){case "left":case "right":return(o.maxDepth-o.minDepth)/(1+r [...]
+o.minBreadth)*m;case "radial":return o.parentNode?(o.innerRadius+o.outerRadius)*Math.cos(o.midAngle):0}}function h(o){switch(p){case "left":case "right":return(o.maxBreadth-o.minBreadth)*n;case "top":case "bottom":return(o.maxDepth-o.minDepth)/(1+r)*n;case "radial":return o.parentNode?(o.innerRadius+o.outerRadius)*Math.sin(o.midAngle):0}}function i(o){return Math.max(0,c(o.minDepth,r/2))*(x-t)+t}function j(o){return c(o.maxDepth,r/2)*(x-t)+t}function k(o){return(o.parentNode?o.minBreadth [...]
+2*Math.PI}function l(o){return(o.parentNode?o.maxBreadth-o.minBreadth:1)*2*Math.PI}var s=b.nodes,p=b.orient,q=/^(top|bottom)$/.test(p),m=b.width,n=b.height,r=-s[0].minDepth;if(p=="radial"){var t=b.innerRadius,x=b.outerRadius;if(t==null)t=0;if(t)r*=2;if(x==null)x=Math.min(m,n)/2}for(b=0;b<s.length;b++){var u=s[b];u.x=d(u);u.y=f(u);if(p=="radial"){u.innerRadius=i(u);u.outerRadius=j(u);u.startAngle=k(u);u.angle=l(u);u.midAngle=u.startAngle+u.angle/2}else u.midAngle=q?-Math.PI/2:0;u.dx=g(u); [...]
+pv.Layout.Grid=function(){pv.Layout.call(this);var b=this;(this.cell=(new pv.Mark).data(function(){return b.scene[b.index].$grid}).width(function(){return b.width()/b.cols()}).height(function(){return b.height()/b.rows()}).left(function(){return this.width()*(this.index%b.cols())}).top(function(){return this.height()*Math.floor(this.index/b.cols())})).parent=this};pv.Layout.Grid.prototype=pv.extend(pv.Layout).property("rows").property("cols");pv.Layout.Grid.prototype.defaults=(new pv.Lay [...]
+pv.Layout.Grid.prototype.buildImplied=function(b){pv.Layout.prototype.buildImplied.call(this,b);var c=b.rows,d=b.cols;if(typeof d=="object")c=pv.transpose(d);if(typeof c=="object"){b.$grid=pv.blend(c);b.rows=c.length;b.cols=c[0]?c[0].length:0}else b.$grid=pv.repeat([b.data],c*d)};
+pv.Layout.Stack=function(){function b(i){return function(){return f[i](this.parent.index,this.index)}}pv.Layout.call(this);var c=this,d=function(){return null},f={t:d,l:d,r:d,b:d,w:d,h:d},g,h=c.buildImplied;this.buildImplied=function(i){h.call(this,i);var j=i.layers,k=j.length,l,s=i.orient,p=/^(top|bottom)\b/.test(s),q=this.parent[p?"height":"width"](),m=[],n=[],r=[],t=pv.Mark.stack,x={parent:{parent:this}};t.unshift(null);g=[];for(var u=0;u<k;u++){r[u]=[];n[u]=[];x.parent.index=u;t[0]=j [...]
+this.$values.apply(x.parent,t);if(!u)l=g[u].length;t.unshift(null);for(var o=0;o<l;o++){t[0]=g[u][o];x.index=o;u||(m[o]=this.$x.apply(x,t));r[u][o]=this.$y.apply(x,t)}t.shift()}t.shift();switch(i.order){case "inside-out":var v=r.map(function(A){return pv.max.index(A)});x=pv.range(k).sort(function(A,D){return v[A]-v[D]});j=r.map(function(A){return pv.sum(A)});var w=t=0,y=[],z=[];for(u=0;u<k;u++){o=x[u];if(t<w){t+=j[o];y.push(o)}else{w+=j[o];z.push(o)}}j=z.reverse().concat(y);break;case "r [...]
+pv.range(k-1,-1,-1);break;default:j=pv.range(k);break}switch(i.offset){case "silohouette":for(o=0;o<l;o++){for(u=x=0;u<k;u++)x+=r[u][o];n[j[0]][o]=(q-x)/2}break;case "wiggle":for(u=x=0;u<k;u++)x+=r[u][0];n[j[0]][0]=x=(q-x)/2;for(o=1;o<l;o++){t=q=0;w=m[o]-m[o-1];for(u=0;u<k;u++)q+=r[u][o];for(u=0;u<k;u++){y=(r[j[u]][o]-r[j[u]][o-1])/(2*w);for(i=0;i<u;i++)y+=(r[j[i]][o]-r[j[i]][o-1])/w;t+=y*r[j[u]][o]}n[j[0]][o]=x-=q?t/q*w:0}break;case "expand":for(o=0;o<l;o++){for(u=i=n[j[0]][o]=0;u<k;u++ [...]
+if(i){i=q/i;for(u=0;u<k;u++)r[u][o]*=i}else{i=q/k;for(u=0;u<k;u++)r[u][o]=i}}break;default:for(o=0;o<l;o++)n[j[0]][o]=0;break}for(o=0;o<l;o++){x=n[j[0]][o];for(u=1;u<k;u++){x+=r[j[u-1]][o];n[j[u]][o]=x}}u=s.indexOf("-");k=p?"h":"w";p=u<0?p?"l":"b":s.charAt(u+1);s=s.charAt(0);for(var C in f)f[C]=d;f[p]=function(A,D){return m[D]};f[s]=function(A,D){return n[A][D]};f[k]=function(A,D){return r[A][D]}};this.layer=(new pv.Mark).data(function(){return g[this.parent.index]}).top(b("t")).left(b(" [...]
+this.layer.add=function(i){return c.add(pv.Panel).data(function(){return c.layers()}).add(i).extend(this)}};pv.Layout.Stack.prototype=pv.extend(pv.Layout).property("orient",String).property("offset",String).property("order",String).property("layers");a=pv.Layout.Stack.prototype;a.defaults=(new pv.Layout.Stack).extend(pv.Layout.prototype.defaults).orient("bottom-left").offset("zero").layers([[]]);a.$x=pv.Layout.Stack.prototype.$y=function(){return 0};a.x=function(b){this.$x=pv.functor(b); [...]
+a.y=function(b){this.$y=pv.functor(b);return this};a.$values=pv.identity;a.values=function(b){this.$values=pv.functor(b);return this};
+pv.Layout.Treemap=function(){pv.Layout.Hierarchy.call(this);this.node.strokeStyle("#fff").fillStyle("rgba(31, 119, 180, .25)").width(function(b){return b.dx}).height(function(b){return b.dy});this.label.visible(function(b){return!b.firstChild}).left(function(b){return b.x+b.dx/2}).top(function(b){return b.y+b.dy/2}).textAlign("center").textAngle(function(b){return b.dx>b.dy?0:-Math.PI/2});(this.leaf=(new pv.Mark).extend(this.node).fillStyle(null).strokeStyle(null).visible(function(b){ret [...]
+this;delete this.link};pv.Layout.Treemap.prototype=pv.extend(pv.Layout.Hierarchy).property("round",Boolean).property("paddingLeft",Number).property("paddingRight",Number).property("paddingTop",Number).property("paddingBottom",Number).property("mode",String).property("order",String);a=pv.Layout.Treemap.prototype;a.defaults=(new pv.Layout.Treemap).extend(pv.Layout.Hierarchy.prototype.defaults).mode("squarify").order("ascending");a.padding=function(b){return this.paddingLeft(b).paddingRight [...]
+a.$size=function(b){return Number(b.nodeValue)};a.size=function(b){this.$size=pv.functor(b);return this};
+a.buildImplied=function(b){function c(n,r,t,x,u,o,v){for(var w=0,y=0;w<n.length;w++){var z=n[w];if(t){z.x=x+y;z.y=u;y+=z.dx=q(o*z.size/r);z.dy=v}else{z.x=x;z.y=u+y;z.dx=o;y+=z.dy=q(v*z.size/r)}}if(z)if(t)z.dx+=o-y;else z.dy+=v-y}function d(n,r){for(var t=-Infinity,x=Infinity,u=0,o=0;o<n.length;o++){var v=n[o].size;if(v<x)x=v;if(v>t)t=v;u+=v}u*=u;r*=r;return Math.max(r*t/u,u/(r*x))}function f(n,r){function t(A){var D=o==y,G=pv.sum(A,p),E=y?q(G/y):0;c(A,G,D,x,u,D?o:E,D?E:v);if(D){u+=E;v-=E [...]
+E;o-=E}y=Math.min(o,v);return D}var x=n.x+j,u=n.y+l,o=n.dx-j-k,v=n.dy-l-s;if(m!="squarify")c(n.childNodes,n.size,m=="slice"?true:m=="dice"?false:r&1,x,u,o,v);else{var w=[];r=Infinity;var y=Math.min(o,v),z=o*v/n.size;if(!(n.size<=0)){n.visitBefore(function(A){A.size*=z});for(n=n.childNodes.slice();n.length;){var C=n[n.length-1];if(C.size){w.push(C);z=d(w,y);if(z<=r){n.pop();r=z}else{w.pop();t(w);w.length=0;r=Infinity}}else n.pop()}if(t(w))for(r=0;r<w.length;r++)w[r].dy+=v;else for(r=0;r<w [...]
+o}}}if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var g=this,h=b.nodes[0],i=pv.Mark.stack,j=b.paddingLeft,k=b.paddingRight,l=b.paddingTop,s=b.paddingBottom,p=function(n){return n.size},q=b.round?Math.round:Number,m=b.mode;i.unshift(null);h.visitAfter(function(n,r){n.depth=r;n.x=n.y=n.dx=n.dy=0;n.size=n.firstChild?pv.sum(n.childNodes,function(t){return t.size}):g.$size.apply(g,(i[0]=n,i))});i.shift();switch(b.order){case "ascending":h.sort(function(n,r){return n.size-r.size [...]
+case "descending":h.sort(function(n,r){return r.size-n.size});break;case "reverse":h.reverse();break}h.x=0;h.y=0;h.dx=b.width;h.dy=b.height;h.visitBefore(f)}};pv.Layout.Tree=function(){pv.Layout.Hierarchy.call(this)};pv.Layout.Tree.prototype=pv.extend(pv.Layout.Hierarchy).property("group",Number).property("breadth",Number).property("depth",Number).property("orient",String);pv.Layout.Tree.prototype.defaults=(new pv.Layout.Tree).extend(pv.Layout.Hierarchy.prototype.defaults).group(1).bread [...]
+pv.Layout.Tree.prototype.buildImplied=function(b){function c(o){var v,w,y;if(o.firstChild){v=o.firstChild;w=o.lastChild;for(var z=y=v;z;z=z.nextSibling){c(z);y=f(z,y)}j(o);w=0.5*(v.prelim+w.prelim);if(v=o.previousSibling){o.prelim=v.prelim+l(o.depth,true);o.mod=o.prelim-w}else o.prelim=w}else if(v=o.previousSibling)o.prelim=v.prelim+l(o.depth,true)}function d(o,v,w){o.breadth=o.prelim+v;v+=o.mod;for(o=o.firstChild;o;o=o.nextSibling)d(o,v,w)}function f(o,v){var w=o.previousSibling;if(w){v [...]
+o,C=w;w=o.parentNode.firstChild;var A=y.mod,D=z.mod,G=C.mod,E=w.mod;C=h(C);for(y=g(y);C&&y;){C=C;y=y;w=g(w);z=h(z);z.ancestor=o;var B=C.prelim+G-(y.prelim+A)+l(C.depth,false);if(B>0){i(k(C,o,v),o,B);A+=B;D+=B}G+=C.mod;A+=y.mod;E+=w.mod;D+=z.mod;C=h(C);y=g(y)}if(C&&!h(z)){z.thread=C;z.mod+=G-D}if(y&&!g(w)){w.thread=y;w.mod+=A-E;v=o}}return v}function g(o){return o.firstChild||o.thread}function h(o){return o.lastChild||o.thread}function i(o,v,w){var y=v.number-o.number;v.change-=w/y;v.shif [...]
+w/y;v.prelim+=w;v.mod+=w}function j(o){var v=0,w=0;for(o=o.lastChild;o;o=o.previousSibling){o.prelim+=v;o.mod+=v;w+=o.change;v+=o.shift+w}}function k(o,v,w){return o.ancestor.parentNode==v.parentNode?o.ancestor:w}function l(o,v){return(v?1:t+1)/(m=="radial"?o:1)}function s(o){return m=="radial"?o.breadth/n:0}function p(o){switch(m){case "left":return o.depth;case "right":return x-o.depth;case "top":case "bottom":return o.breadth+x/2;case "radial":return x/2+o.depth*Math.cos(s(o))}}functi [...]
+u/2;case "top":return o.depth;case "bottom":return u-o.depth;case "radial":return u/2+o.depth*Math.sin(s(o))}}if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var m=b.orient,n=b.depth,r=b.breadth,t=b.group,x=b.width,u=b.height;b=b.nodes[0];b.visitAfter(function(o,v){o.ancestor=o;o.prelim=0;o.mod=0;o.change=0;o.shift=0;o.number=o.previousSibling?o.previousSibling.number+1:0;o.depth=v});c(b);d(b,-b.prelim,0);b.visitAfter(function(o){o.breadth*=r;o.depth*=n;o.midAngle=s(o);o.x=p [...]
+if(o.firstChild)o.midAngle+=Math.PI;delete o.breadth;delete o.depth;delete o.ancestor;delete o.prelim;delete o.mod;delete o.change;delete o.shift;delete o.number;delete o.thread})}};pv.Layout.Indent=function(){pv.Layout.Hierarchy.call(this);this.link.interpolate("step-after")};pv.Layout.Indent.prototype=pv.extend(pv.Layout.Hierarchy).property("depth",Number).property("breadth",Number);pv.Layout.Indent.prototype.defaults=(new pv.Layout.Indent).extend(pv.Layout.Hierarchy.prototype.defaults [...]
+pv.Layout.Indent.prototype.buildImplied=function(b){function c(i,j,k){i.x=g+k++*f;i.y=h+j++*d;i.midAngle=0;for(i=i.firstChild;i;i=i.nextSibling)j=c(i,j,k);return j}if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var d=b.breadth,f=b.depth,g=0,h=0;c(b.nodes[0],1,1)}};pv.Layout.Pack=function(){pv.Layout.Hierarchy.call(this);this.node.shapeRadius(function(b){return b.radius}).strokeStyle("rgb(31, 119, 180)").fillStyle("rgba(31, 119, 180, .25)");this.label.textAlign("center");del [...]
+pv.Layout.Pack.prototype=pv.extend(pv.Layout.Hierarchy).property("spacing",Number).property("order",String);pv.Layout.Pack.prototype.defaults=(new pv.Layout.Pack).extend(pv.Layout.Hierarchy.prototype.defaults).spacing(1).order("ascending");pv.Layout.Pack.prototype.$radius=function(){return 1};pv.Layout.Pack.prototype.size=function(b){this.$radius=typeof b=="function"?function(){return Math.sqrt(b.apply(this,arguments))}:(b=Math.sqrt(b),function(){return b});return this};
+pv.Layout.Pack.prototype.buildImplied=function(b){function c(p){var q=pv.Mark.stack;q.unshift(null);for(var m=0,n=p.length;m<n;m++){var r=p[m];if(!r.firstChild)r.radius=i.$radius.apply(i,(q[0]=r,q))}q.shift()}function d(p){var q=[];for(p=p.firstChild;p;p=p.nextSibling){if(p.firstChild)p.radius=d(p);p.n=p.p=p;q.push(p)}switch(b.order){case "ascending":q.sort(function(m,n){return m.radius-n.radius});break;case "descending":q.sort(function(m,n){return n.radius-m.radius});break;case "reverse [...]
+break}return f(q)}function f(p){function q(B){t=Math.min(B.x-B.radius,t);x=Math.max(B.x+B.radius,x);u=Math.min(B.y-B.radius,u);o=Math.max(B.y+B.radius,o)}function m(B,F){var H=B.n;B.n=F;F.p=B;F.n=H;H.p=F}function n(B,F){B.n=F;F.p=B}function r(B,F){var H=F.x-B.x,I=F.y-B.y;B=B.radius+F.radius;return B*B-H*H-I*I>0.0010}var t=Infinity,x=-Infinity,u=Infinity,o=-Infinity,v,w,y,z,C;v=p[0];v.x=-v.radius;v.y=0;q(v);if(p.length>1){w=p[1];w.x=w.radius;w.y=0;q(w);if(p.length>2){y=p[2];g(v,w,y);q(y); [...]
+y;m(y,w);w=v.n;for(var A=3;A<p.length;A++){g(v,w,y=p[A]);var D=0,G=1,E=1;for(z=w.n;z!=w;z=z.n,G++)if(r(z,y)){D=1;break}if(D==1)for(C=v.p;C!=z.p;C=C.p,E++)if(r(C,y)){if(E<G){D=-1;z=C}break}if(D==0){m(v,y);w=y;q(y)}else if(D>0){n(v,z);w=z;A--}else if(D<0){n(z,w);v=z;A--}}}}v=(t+x)/2;w=(u+o)/2;for(A=y=0;A<p.length;A++){z=p[A];z.x-=v;z.y-=w;y=Math.max(y,z.radius+Math.sqrt(z.x*z.x+z.y*z.y))}return y+b.spacing}function g(p,q,m){var n=q.radius+m.radius,r=p.radius+m.radius,t=q.x-p.x;q=q.y-p.y;va [...]
+t+q*q),u=(r*r+x*x-n*n)/(2*r*x);n=Math.acos(u);u=u*r;r=Math.sin(n)*r;t/=x;q/=x;m.x=p.x+u*t+r*q;m.y=p.y+u*q-r*t}function h(p,q,m,n){for(var r=p.firstChild;r;r=r.nextSibling){r.x+=p.x;r.y+=p.y;h(r,q,m,n)}p.x=q+n*p.x;p.y=m+n*p.y;p.radius*=n}if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var i=this,j=b.nodes,k=j[0];c(j);k.x=0;k.y=0;k.radius=d(k);j=this.width();var l=this.height(),s=1/Math.max(2*k.radius/j,2*k.radius/l);h(k,j/2,l/2,s)}};
+pv.Layout.Force=function(){pv.Layout.Network.call(this);this.link.lineWidth(function(b,c){return Math.sqrt(c.linkValue)*1.5});this.label.textAlign("center")};
+pv.Layout.Force.prototype=pv.extend(pv.Layout.Network).property("bound",Boolean).property("iterations",Number).property("dragConstant",Number).property("chargeConstant",Number).property("chargeMinDistance",Number).property("chargeMaxDistance",Number).property("chargeTheta",Number).property("springConstant",Number).property("springDamping",Number).property("springLength",Number);pv.Layout.Force.prototype.defaults=(new pv.Layout.Force).extend(pv.Layout.Network.prototype.defaults).dragConst [...]
+pv.Layout.Force.prototype.buildImplied=function(b){function c(s){return s.fix?1:s.vx*s.vx+s.vy*s.vy}if(pv.Layout.Network.prototype.buildImplied.call(this,b)){if(b=b.$force){b.next=this.binds.$force;this.binds.$force=b}}else{for(var d=this,f=b.nodes,g=b.links,h=b.iterations,i=b.width,j=b.height,k=0,l;k<f.length;k++){l=f[k];if(isNaN(l.x))l.x=i/2+40*Math.random()-20;if(isNaN(l.y))l.y=j/2+40*Math.random()-20}l=pv.simulation(f);l.force(pv.Force.drag(b.dragConstant));l.force(pv.Force.charge(b. [...]
+b.chargeMaxDistance).theta(b.chargeTheta));l.force(pv.Force.spring(b.springConstant).damping(b.springDamping).length(b.springLength).links(g));l.constraint(pv.Constraint.position());b.bound&&l.constraint(pv.Constraint.bound().x(6,i-6).y(6,j-6));if(h==null){l.step();l.step();b.$force=this.binds.$force={next:this.binds.$force,nodes:f,min:1.0E-4*(g.length+1),sim:l};if(!this.$timer)this.$timer=setInterval(function(){for(var s=false,p=d.binds.$force;p;p=p.next)if(pv.max(p.nodes,c)>p.min){p.si [...]
+s=true}s&&d.render()},42)}else for(k=0;k<h;k++)l.step()}};pv.Layout.Cluster=function(){pv.Layout.Hierarchy.call(this);var b,c=this.buildImplied;this.buildImplied=function(d){c.call(this,d);b=/^(top|bottom)$/.test(d.orient)?"step-before":/^(left|right)$/.test(d.orient)?"step-after":"linear"};this.link.interpolate(function(){return b})};
+pv.Layout.Cluster.prototype=pv.extend(pv.Layout.Hierarchy).property("group",Number).property("orient",String).property("innerRadius",Number).property("outerRadius",Number);pv.Layout.Cluster.prototype.defaults=(new pv.Layout.Cluster).extend(pv.Layout.Hierarchy.prototype.defaults).group(0).orient("top");
+pv.Layout.Cluster.prototype.buildImplied=function(b){if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var c=b.nodes[0],d=b.group,f,g,h=0,i=0.5-d/2,j=undefined;c.visitAfter(function(k){if(k.firstChild)k.depth=1+pv.max(k.childNodes,function(l){return l.depth});else{if(d&&j!=k.parentNode){j=k.parentNode;h+=d}h++;k.depth=0}});f=1/h;g=1/c.depth;j=undefined;c.visitAfter(function(k){if(k.firstChild)k.breadth=pv.mean(k.childNodes,function(l){return l.breadth});else{if(d&&j!=k.parentN [...]
+i+=d}k.breadth=f*i++}k.depth=1-k.depth*g});c.visitAfter(function(k){k.minBreadth=k.firstChild?k.firstChild.minBreadth:k.breadth-f/2;k.maxBreadth=k.firstChild?k.lastChild.maxBreadth:k.breadth+f/2});c.visitBefore(function(k){k.minDepth=k.parentNode?k.parentNode.maxDepth:0;k.maxDepth=k.parentNode?k.depth+c.depth:k.minDepth+2*c.depth});c.minDepth=-g;pv.Layout.Hierarchy.NodeLink.buildImplied.call(this,b)}};pv.Layout.Cluster.Fill=function(){pv.Layout.Cluster.call(this);pv.Layout.Hierarchy.Fill [...]
+pv.Layout.Cluster.Fill.prototype=pv.extend(pv.Layout.Cluster);pv.Layout.Cluster.Fill.prototype.buildImplied=function(b){pv.Layout.Cluster.prototype.buildImplied.call(this,b)||pv.Layout.Hierarchy.Fill.buildImplied.call(this,b)};pv.Layout.Partition=function(){pv.Layout.Hierarchy.call(this)};pv.Layout.Partition.prototype=pv.extend(pv.Layout.Hierarchy).property("order",String).property("orient",String).property("innerRadius",Number).property("outerRadius",Number);
+pv.Layout.Partition.prototype.defaults=(new pv.Layout.Partition).extend(pv.Layout.Hierarchy.prototype.defaults).orient("top");pv.Layout.Partition.prototype.$size=function(){return 1};pv.Layout.Partition.prototype.size=function(b){this.$size=b;return this};
+pv.Layout.Partition.prototype.buildImplied=function(b){if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var c=this,d=b.nodes[0],f=pv.Mark.stack,g=0;f.unshift(null);d.visitAfter(function(i,j){if(j>g)g=j;i.size=i.firstChild?pv.sum(i.childNodes,function(k){return k.size}):c.$size.apply(c,(f[0]=i,f))});f.shift();switch(b.order){case "ascending":d.sort(function(i,j){return i.size-j.size});break;case "descending":d.sort(function(i,j){return j.size-i.size});break}var h=1/g;d.minBrea [...]
+0.5;d.maxBreadth=1;d.visitBefore(function(i){for(var j=i.minBreadth,k=i.maxBreadth-j,l=i.firstChild;l;l=l.nextSibling){l.minBreadth=j;l.maxBreadth=j+=l.size/i.size*k;l.breadth=(j+l.minBreadth)/2}});d.visitAfter(function(i,j){i.minDepth=(j-1)*h;i.maxDepth=i.depth=j*h});pv.Layout.Hierarchy.NodeLink.buildImplied.call(this,b)}};pv.Layout.Partition.Fill=function(){pv.Layout.Partition.call(this);pv.Layout.Hierarchy.Fill.constructor.call(this)};pv.Layout.Partition.Fill.prototype=pv.extend(pv.La [...]
+pv.Layout.Partition.Fill.prototype.buildImplied=function(b){pv.Layout.Partition.prototype.buildImplied.call(this,b)||pv.Layout.Hierarchy.Fill.buildImplied.call(this,b)};pv.Layout.Arc=function(){pv.Layout.Network.call(this);var b,c,d,f=this.buildImplied;this.buildImplied=function(g){f.call(this,g);c=g.directed;b=g.orient=="radial"?"linear":"polar";d=g.orient=="right"||g.orient=="top"};this.link.data(function(g){var h=g.sourceNode;g=g.targetNode;return d!=(c||h.breadth<g.breadth)?[h,g]:[g, [...]
+pv.Layout.Arc.prototype=pv.extend(pv.Layout.Network).property("orient",String).property("directed",Boolean);pv.Layout.Arc.prototype.defaults=(new pv.Layout.Arc).extend(pv.Layout.Network.prototype.defaults).orient("bottom");pv.Layout.Arc.prototype.sort=function(b){this.$sort=b;return this};
+pv.Layout.Arc.prototype.buildImplied=function(b){function c(m){switch(h){case "top":return-Math.PI/2;case "bottom":return Math.PI/2;case "left":return Math.PI;case "right":return 0;case "radial":return(m-0.25)*2*Math.PI}}function d(m){switch(h){case "top":case "bottom":return m*k;case "left":return 0;case "right":return k;case "radial":return k/2+s*Math.cos(c(m))}}function f(m){switch(h){case "top":return 0;case "bottom":return l;case "left":case "right":return m*l;case "radial":return l [...]
+if(!pv.Layout.Network.prototype.buildImplied.call(this,b)){var g=b.nodes,h=b.orient,i=this.$sort,j=pv.range(g.length),k=b.width,l=b.height,s=Math.min(k,l)/2;i&&j.sort(function(m,n){return i(g[m],g[n])});for(b=0;b<g.length;b++){var p=g[j[b]],q=p.breadth=(b+0.5)/g.length;p.x=d(q);p.y=f(q);p.midAngle=c(q)}}};
+pv.Layout.Horizon=function(){pv.Layout.call(this);var b=this,c,d,f,g,h,i,j=this.buildImplied;this.buildImplied=function(k){j.call(this,k);c=k.bands;d=k.mode;f=Math.round((d=="color"?0.5:1)*k.height);g=k.backgroundStyle;h=pv.ramp(g,k.negativeStyle).domain(0,c);i=pv.ramp(g,k.positiveStyle).domain(0,c)};c=(new pv.Panel).data(function(){return pv.range(c*2)}).overflow("hidden").height(function(){return f}).top(function(k){return d=="color"?(k&1)*f:0}).fillStyle(function(k){return k?null:g}); [...]
+(new pv.Mark).top(function(k,l){return d=="mirror"&&l&1?(l+1>>1)*f:null}).bottom(function(k,l){return d=="mirror"?l&1?null:(l+1>>1)*-f:(l&1||-1)*(l+1>>1)*f}).fillStyle(function(k,l){return(l&1?h:i)((l>>1)+1)});this.band.add=function(k){return b.add(pv.Panel).extend(c).add(k).extend(this)}};pv.Layout.Horizon.prototype=pv.extend(pv.Layout).property("bands",Number).property("mode",String).property("backgroundStyle",pv.color).property("positiveStyle",pv.color).property("negativeStyle",pv.color);
+pv.Layout.Horizon.prototype.defaults=(new pv.Layout.Horizon).extend(pv.Layout.prototype.defaults).bands(2).mode("offset").backgroundStyle("white").positiveStyle("#1f77b4").negativeStyle("#d62728");
+pv.Layout.Rollup=function(){pv.Layout.Network.call(this);var b=this,c,d,f=b.buildImplied;this.buildImplied=function(g){f.call(this,g);c=g.$rollup.nodes;d=g.$rollup.links};this.node.data(function(){return c}).shapeSize(function(g){return g.nodes.length*20});this.link.interpolate("polar").eccentricity(0.8);this.link.add=function(g){return b.add(pv.Panel).data(function(){return d}).add(g).extend(this)}};pv.Layout.Rollup.prototype=pv.extend(pv.Layout.Network).property("directed",Boolean);
+pv.Layout.Rollup.prototype.x=function(b){this.$x=pv.functor(b);return this};pv.Layout.Rollup.prototype.y=function(b){this.$y=pv.functor(b);return this};
+pv.Layout.Rollup.prototype.buildImplied=function(b){function c(n){return i[n]+","+j[n]}if(!pv.Layout.Network.prototype.buildImplied.call(this,b)){var d=b.nodes,f=b.links,g=b.directed,h=d.length,i=[],j=[],k=0,l={},s={},p=pv.Mark.stack,q={parent:this};p.unshift(null);for(var m=0;m<h;m++){q.index=m;p[0]=d[m];i[m]=this.$x.apply(q,p);j[m]=this.$y.apply(q,p)}p.shift();for(m=0;m<d.length;m++){h=c(m);p=l[h];if(!p){p=l[h]=pv.extend(d[m]);p.index=k++;p.x=i[m];p.y=j[m];p.nodes=[]}p.nodes.push(d[m]) [...]
+f.length;m++){k=f[m].targetNode;d=l[c(f[m].sourceNode.index)];k=l[c(k.index)];h=!g&&d.index>k.index?k.index+","+d.index:d.index+","+k.index;(p=s[h])||(p=s[h]={sourceNode:d,targetNode:k,linkValue:0,links:[]});p.links.push(f[m]);p.linkValue+=f[m].linkValue}b.$rollup={nodes:pv.values(l),links:pv.values(s)}}};
+pv.Layout.Matrix=function(){pv.Layout.Network.call(this);var b,c,d,f,g,h=this.buildImplied;this.buildImplied=function(i){h.call(this,i);b=i.nodes.length;c=i.width/b;d=i.height/b;f=i.$matrix.labels;g=i.$matrix.pairs};this.link.data(function(){return g}).left(function(){return c*(this.index%b)}).top(function(){return d*Math.floor(this.index/b)}).width(function(){return c}).height(function(){return d}).lineWidth(1.5).strokeStyle("#fff").fillStyle(function(i){return i.linkValue?"#555":"#eee" [...]
+this;delete this.link.add;this.label.data(function(){return f}).left(function(){return this.index&1?c*((this.index>>1)+0.5):0}).top(function(){return this.index&1?0:d*((this.index>>1)+0.5)}).textMargin(4).textAlign(function(){return this.index&1?"left":"right"}).textAngle(function(){return this.index&1?-Math.PI/2:0});delete this.node};pv.Layout.Matrix.prototype=pv.extend(pv.Layout.Network).property("directed",Boolean);pv.Layout.Matrix.prototype.sort=function(b){this.$sort=b;return this};
+pv.Layout.Matrix.prototype.buildImplied=function(b){if(!pv.Layout.Network.prototype.buildImplied.call(this,b)){var c=b.nodes,d=b.links,f=this.$sort,g=c.length,h=pv.range(g),i=[],j=[],k={};b.$matrix={labels:i,pairs:j};f&&h.sort(function(m,n){return f(c[m],c[n])});for(var l=0;l<g;l++)for(var s=0;s<g;s++){var p=h[l],q=h[s];j.push(k[p+"."+q]={row:l,col:s,sourceNode:c[p],targetNode:c[q],linkValue:0})}for(l=0;l<g;l++){p=h[l];i.push(c[p],c[p])}for(l=0;l<d.length;l++){i=d[l];g=i.sourceNode.index [...]
+i=i.linkValue;k[g+"."+h].linkValue+=i;b.directed||(k[h+"."+g].linkValue+=i)}}};
+pv.Layout.Bullet=function(){pv.Layout.call(this);var b=this,c=b.buildImplied,d=b.x=pv.Scale.linear(),f,g,h,i,j;this.buildImplied=function(k){c.call(this,j=k);f=k.orient;g=/^left|right$/.test(f);h=pv.ramp("#bbb","#eee").domain(0,Math.max(1,j.ranges.length-1));i=pv.ramp("steelblue","lightsteelblue").domain(0,Math.max(1,j.measures.length-1))};(this.range=new pv.Mark).data(function(){return j.ranges}).reverse(true).left(function(){return f=="left"?0:null}).top(function(){return f=="top"?0:nu [...]
+"right"?0:null}).bottom(function(){return f=="bottom"?0:null}).width(function(k){return g?d(k):null}).height(function(k){return g?null:d(k)}).fillStyle(function(){return h(this.index)}).antialias(false).parent=b;(this.measure=new pv.Mark).extend(this.range).data(function(){return j.measures}).left(function(){return f=="left"?0:g?null:this.parent.width()/3.25}).top(function(){return f=="top"?0:g?this.parent.height()/3.25:null}).right(function(){return f=="right"?0:g?null:this.parent.width [...]
+"bottom"?0:g?this.parent.height()/3.25:null}).fillStyle(function(){return i(this.index)}).parent=b;(this.marker=new pv.Mark).data(function(){return j.markers}).left(function(k){return f=="left"?d(k):g?null:this.parent.width()/2}).top(function(k){return f=="top"?d(k):g?this.parent.height()/2:null}).right(function(k){return f=="right"?d(k):null}).bottom(function(k){return f=="bottom"?d(k):null}).strokeStyle("black").shape("bar").shapeAngle(function(){return g?0:Math.PI/2}).parent=b;(this.t [...]
+"left"?d(k):null}).top(function(k){return f=="top"?d(k):null}).right(function(k){return f=="right"?d(k):g?null:-6}).bottom(function(k){return f=="bottom"?d(k):g?-8:null}).height(function(){return g?6:null}).width(function(){return g?null:6}).parent=b};pv.Layout.Bullet.prototype=pv.extend(pv.Layout).property("orient",String).property("ranges").property("markers").property("measures").property("maximum",Number);pv.Layout.Bullet.prototype.defaults=(new pv.Layout.Bullet).extend(pv.Layout.pro [...]
+pv.Layout.Bullet.prototype.buildImplied=function(b){pv.Layout.prototype.buildImplied.call(this,b);var c=this.parent[/^left|right$/.test(b.orient)?"width":"height"]();b.maximum=b.maximum||pv.max([].concat(b.ranges,b.markers,b.measures));this.x.domain(0,b.maximum).range(0,c)};pv.Behavior={};
+pv.Behavior.drag=function(){function b(k){g=this.index;f=this.scene;var l=this.mouse();i=((h=k).fix=pv.vector(k.x,k.y)).minus(l);j={x:this.parent.width()-(k.dx||0),y:this.parent.height()-(k.dy||0)};f.mark.context(f,g,function(){this.render()});pv.Mark.dispatch("dragstart",f,g)}function c(){if(f){f.mark.context(f,g,function(){var k=this.mouse();h.x=h.fix.x=Math.max(0,Math.min(i.x+k.x,j.x));h.y=h.fix.y=Math.max(0,Math.min(i.y+k.y,j.y));this.render()});pv.Mark.dispatch("drag",f,g)}}function [...]
+null;f.mark.context(f,g,function(){this.render()});pv.Mark.dispatch("dragend",f,g);f=null}}var f,g,h,i,j;pv.listen(window,"mousemove",c);pv.listen(window,"mouseup",d);return b};
+pv.Behavior.point=function(b){function c(l,s){l=l[s];s={cost:Infinity};for(var p=0,q=l.visible&&l.children.length;p<q;p++){var m=l.children[p],n=m.mark,r;if(n.type=="panel"){n.scene=m;for(var t=0,x=m.length;t<x;t++){n.index=t;r=c(m,t);if(r.cost<s.cost)s=r}delete n.scene;delete n.index}else if(n.$handlers.point){n=n.mouse();t=0;for(x=m.length;t<x;t++){var u=m[t];r=n.x-u.left-(u.width||0)/2;u=n.y-u.top-(u.height||0)/2;var o=i*r*r+j*u*u;if(o<s.cost){s.distance=r*r+u*u;s.cost=o;s.scene=m;s.i [...]
+function d(){var l=c(this.scene,this.index);if(l.cost==Infinity||l.distance>k)l=null;if(g){if(l&&g.scene==l.scene&&g.index==l.index)return;pv.Mark.dispatch("unpoint",g.scene,g.index)}if(g=l){pv.Mark.dispatch("point",l.scene,l.index);pv.listen(this.root.canvas(),"mouseout",f)}}function f(l){if(g&&!pv.ancestor(this,l.relatedTarget)){pv.Mark.dispatch("unpoint",g.scene,g.index);g=null}}var g,h=null,i=1,j=1,k=arguments.length?b*b:900;d.collapse=function(l){if(arguments.length){h=String(l);swi [...]
+1;j=0;break;case "x":i=0;j=1;break;default:j=i=1;break}return d}return h};return d};
+pv.Behavior.select=function(){function b(j){g=this.index;f=this.scene;i=this.mouse();h=j;h.x=i.x;h.y=i.y;h.dx=h.dy=0;pv.Mark.dispatch("selectstart",f,g)}function c(){if(f){f.mark.context(f,g,function(){var j=this.mouse();h.x=Math.max(0,Math.min(i.x,j.x));h.y=Math.max(0,Math.min(i.y,j.y));h.dx=Math.min(this.width(),Math.max(j.x,i.x))-h.x;h.dy=Math.min(this.height(),Math.max(j.y,i.y))-h.y;this.render()});pv.Mark.dispatch("select",f,g)}}function d(){if(f){pv.Mark.dispatch("selectend",f,g);f [...]
+g,h,i;pv.listen(window,"mousemove",c);pv.listen(window,"mouseup",d);return b};
+pv.Behavior.resize=function(b){function c(k){h=this.index;g=this.scene;j=this.mouse();i=k;switch(b){case "left":j.x=i.x+i.dx;break;case "right":j.x=i.x;break;case "top":j.y=i.y+i.dy;break;case "bottom":j.y=i.y;break}pv.Mark.dispatch("resizestart",g,h)}function d(){if(g){g.mark.context(g,h,function(){var k=this.mouse();i.x=Math.max(0,Math.min(j.x,k.x));i.y=Math.max(0,Math.min(j.y,k.y));i.dx=Math.min(this.parent.width(),Math.max(k.x,j.x))-i.x;i.dy=Math.min(this.parent.height(),Math.max(k.y [...]
+this.render()});pv.Mark.dispatch("resize",g,h)}}function f(){if(g){pv.Mark.dispatch("resizeend",g,h);g=null}}var g,h,i,j;pv.listen(window,"mousemove",d);pv.listen(window,"mouseup",f);return c};
+pv.Behavior.pan=function(){function b(){g=this.index;f=this.scene;i=pv.vector(pv.event.pageX,pv.event.pageY);h=this.transform();j=1/(h.k*this.scale);if(k)k={x:(1-h.k)*this.width(),y:(1-h.k)*this.height()}}function c(){if(f){f.mark.context(f,g,function(){var l=h.translate((pv.event.pageX-i.x)*j,(pv.event.pageY-i.y)*j);if(k){l.x=Math.max(k.x,Math.min(0,l.x));l.y=Math.max(k.y,Math.min(0,l.y))}this.transform(l).render()});pv.Mark.dispatch("pan",f,g)}}function d(){f=null}var f,g,h,i,j,k;b.bou [...]
+Boolean(l);return this}return Boolean(k)};pv.listen(window,"mousemove",c);pv.listen(window,"mouseup",d);return b};
+pv.Behavior.zoom=function(b){function c(){var f=this.mouse(),g=pv.event.wheel*b;f=this.transform().translate(f.x,f.y).scale(g<0?1E3/(1E3-g):(1E3+g)/1E3).translate(-f.x,-f.y);if(d){f.k=Math.max(1,f.k);f.x=Math.max((1-f.k)*this.width(),Math.min(0,f.x));f.y=Math.max((1-f.k)*this.height(),Math.min(0,f.y))}this.transform(f).render();pv.Mark.dispatch("zoom",this.scene,this.index)}var d;arguments.length||(b=1/48);c.bound=function(f){if(arguments.length){d=Boolean(f);return this}return Boolean(d [...]
+pv.Geo=function(){};
+pv.Geo.projections={mercator:{project:function(b){return{x:b.lng/180,y:b.lat>85?1:b.lat<-85?-1:Math.log(Math.tan(Math.PI/4+pv.radians(b.lat)/2))/Math.PI}},invert:function(b){return{lng:b.x*180,lat:pv.degrees(2*Math.atan(Math.exp(b.y*Math.PI))-Math.PI/2)}}},"gall-peters":{project:function(b){return{x:b.lng/180,y:Math.sin(pv.radians(b.lat))}},invert:function(b){return{lng:b.x*180,lat:pv.degrees(Math.asin(b.y))}}},sinusoidal:{project:function(b){return{x:pv.radians(b.lng)*Math.cos(pv.radian [...]
+y:b.lat/90}},invert:function(b){return{lng:pv.degrees(b.x*Math.PI/Math.cos(b.y*Math.PI/2)),lat:b.y*90}}},aitoff:{project:function(b){var c=pv.radians(b.lng);b=pv.radians(b.lat);var d=Math.acos(Math.cos(b)*Math.cos(c/2));return{x:2*(d?Math.cos(b)*Math.sin(c/2)*d/Math.sin(d):0)/Math.PI,y:2*(d?Math.sin(b)*d/Math.sin(d):0)/Math.PI}},invert:function(b){var c=b.y*Math.PI/2;return{lng:pv.degrees(b.x*Math.PI/2/Math.cos(c)),lat:pv.degrees(c)}}},hammer:{project:function(b){var c=pv.radians(b.lng); [...]
+var d=Math.sqrt(1+Math.cos(b)*Math.cos(c/2));return{x:2*Math.SQRT2*Math.cos(b)*Math.sin(c/2)/d/3,y:Math.SQRT2*Math.sin(b)/d/1.5}},invert:function(b){var c=b.x*3;b=b.y*1.5;var d=Math.sqrt(1-c*c/16-b*b/4);return{lng:pv.degrees(2*Math.atan2(d*c,2*(2*d*d-1))),lat:pv.degrees(Math.asin(d*b))}}},identity:{project:function(b){return{x:b.lng/180,y:b.lat/90}},invert:function(b){return{lng:b.x*180,lat:b.y*90}}}};
+pv.Geo.scale=function(b){function c(m){if(!p||m.lng!=p.lng||m.lat!=p.lat){p=m;m=d(m);q={x:k(m.x),y:l(m.y)}}return q}function d(m){return j.project({lng:m.lng-s.lng,lat:m.lat})}function f(m){m=j.invert(m);m.lng+=s.lng;return m}var g={x:0,y:0},h={x:1,y:1},i=[],j=pv.Geo.projections.identity,k=pv.Scale.linear(-1,1).range(0,1),l=pv.Scale.linear(-1,1).range(1,0),s={lng:0,lat:0},p,q;c.x=function(m){return c(m).x};c.y=function(m){return c(m).y};c.ticks={lng:function(m){var n;if(i.length>1){var r [...]
+if(m==undefined)m=10;n=r.domain(i,function(t){return t.lat}).ticks(m);m=r.domain(i,function(t){return t.lng}).ticks(m)}else{n=pv.range(-80,81,10);m=pv.range(-180,181,10)}return m.map(function(t){return n.map(function(x){return{lat:x,lng:t}})})},lat:function(m){return pv.transpose(c.ticks.lng(m))}};c.invert=function(m){return f({x:k.invert(m.x),y:l.invert(m.y)})};c.domain=function(m,n){if(arguments.length){i=m instanceof Array?arguments.length>1?pv.map(m,n):m:Array.prototype.slice.call(ar [...]
+if(i.length>1){var r=i.map(function(x){return x.lng}),t=i.map(function(x){return x.lat});s={lng:(pv.max(r)+pv.min(r))/2,lat:(pv.max(t)+pv.min(t))/2};r=i.map(d);k.domain(r,function(x){return x.x});l.domain(r,function(x){return x.y})}else{s={lng:0,lat:0};k.domain(-1,1);l.domain(-1,1)}p=null;return this}return i};c.range=function(m,n){if(arguments.length){if(typeof m=="object"){g={x:Number(m.x),y:Number(m.y)};h={x:Number(n.x),y:Number(n.y)}}else{g={x:0,y:0};h={x:Number(m),y:Number(n)}}k.ran [...]
+l.range(h.y,g.y);p=null;return this}return[g,h]};c.projection=function(m){if(arguments.length){j=typeof m=="string"?pv.Geo.projections[m]||pv.Geo.projections.identity:m;return this.domain(i)}return m};c.by=function(m){function n(){return c(m.apply(this,arguments))}for(var r in c)n[r]=c[r];return n};arguments.length&&c.projection(b);return c};
diff --git a/vendor/protovis/src/behavior/Behavior.js b/vendor/protovis/src/behavior/Behavior.js
new file mode 100644
index 0000000..0f54e1d
--- /dev/null
+++ b/vendor/protovis/src/behavior/Behavior.js
@@ -0,0 +1,32 @@
+/**
+ * Abstract; see an implementing class for details.
+ *
+ * @class Represents a reusable interaction; applies an interactive behavior to
+ * a given mark. Behaviors are themselves functions designed to be used as event
+ * handlers. For example, to add pan and zoom support to any panel, say:
+ *
+ * <pre>    .event("mousedown", pv.Behavior.pan())
+ *     .event("mousewheel", pv.Behavior.zoom())</pre>
+ *
+ * The behavior should be registered on the event that triggers the start of the
+ * behavior. Typically, the behavior will take care of registering for any
+ * additional events that are necessary. For example, dragging starts on
+ * mousedown, while the drag behavior automatically listens for mousemove and
+ * mouseup events on the window. By listening to the window, the behavior can
+ * continue to receive mouse events even if the mouse briefly leaves the mark
+ * being dragged, or even the root panel.
+ *
+ * <p>Each behavior implementation has specific requirements as to which events
+ * it supports, and how it should be used. For example, the drag behavior
+ * requires that the data associated with the mark be an object with <tt>x</tt>
+ * and <tt>y</tt> attributes, such as a {@link pv.Vector}, storing the mark's
+ * position. See an implementing class for details.
+ *
+ * @see pv.Behavior.drag
+ * @see pv.Behavior.pan
+ * @see pv.Behavior.point
+ * @see pv.Behavior.select
+ * @see pv.Behavior.zoom
+ * @extends function
+ */
+pv.Behavior = {};
diff --git a/vendor/protovis/src/behavior/Drag.js b/vendor/protovis/src/behavior/Drag.js
new file mode 100644
index 0000000..6f33fa9
--- /dev/null
+++ b/vendor/protovis/src/behavior/Drag.js
@@ -0,0 +1,112 @@
+/**
+ * Returns a new drag behavior to be registered on mousedown events.
+ *
+ * @class Implements interactive dragging starting with mousedown events.
+ * Register this behavior on marks that should be draggable by the user, such as
+ * the selected region for brushing and linking. This behavior can be used in
+ * tandom with {@link pv.Behavior.select} to allow the selected region to be
+ * dragged interactively.
+ *
+ * <p>After the initial mousedown event is triggered, this behavior listens for
+ * mousemove and mouseup events on the window. This allows dragging to continue
+ * even if the mouse temporarily leaves the mark that is being dragged, or even
+ * the root panel.
+ *
+ * <p>This behavior requires that the data associated with the mark being
+ * dragged have <tt>x</tt> and <tt>y</tt> attributes that correspond to the
+ * mark's location in pixels. The mark's positional properties are not set
+ * directly by this behavior; instead, the positional properties should be
+ * defined as:
+ *
+ * <pre>    .left(function(d) d.x)
+ *     .top(function(d) d.y)</pre>
+ *
+ * Thus, the behavior does not move the mark directly, but instead updates the
+ * mark position by updating the underlying data. Note that if the positional
+ * properties are defined with bottom and right (rather than top and left), the
+ * drag behavior will be inverted, which will confuse users!
+ *
+ * <p>The drag behavior is bounded by the parent panel; the <tt>x</tt> and
+ * <tt>y</tt> attributes are clamped such that the mark being dragged does not
+ * extend outside the enclosing panel's bounds. To facilitate this, the drag
+ * behavior also queries for <tt>dx</tt> and <tt>dy</tt> attributes on the
+ * underlying data, to determine the dimensions of the bar being dragged. For
+ * non-rectangular marks, the drag behavior simply treats the mark as a point,
+ * which means that only the mark's center is bounded.
+ *
+ * <p>The mark being dragged is automatically re-rendered for each mouse event
+ * as part of the drag operation. In addition, a <tt>fix</tt> attribute is
+ * populated on the mark, which allows visual feedback for dragging. For
+ * example, to change the mark fill color while dragging:
+ *
+ * <pre>    .fillStyle(function(d) d.fix ? "#ff7f0e" : "#aec7e8")</pre>
+ *
+ * In some cases, such as with network layouts, dragging the mark may cause
+ * related marks to change, in which case additional marks may also need to be
+ * rendered. This can be accomplished by listening for the drag
+ * psuedo-events:<ul>
+ *
+ * <li>dragstart (on mousedown)
+ * <li>drag (on mousemove)
+ * <li>dragend (on mouseup)
+ *
+ * </ul>For example, to render the parent panel while dragging, thus
+ * re-rendering all sibling marks:
+ *
+ * <pre>    .event("mousedown", pv.Behavior.drag())
+ *     .event("drag", function() this.parent)</pre>
+ *
+ * This behavior may be enhanced in the future to allow more flexible
+ * configuration of drag behavior.
+ *
+ * @extends pv.Behavior
+ * @see pv.Behavior
+ * @see pv.Behavior.select
+ * @see pv.Layout.force
+ */
+pv.Behavior.drag = function() {
+  var scene, // scene context
+      index, // scene context
+      p, // particle being dragged
+      v1, // initial mouse-particle offset
+      max;
+
+  /** @private */
+  function mousedown(d) {
+    index = this.index;
+    scene = this.scene;
+    var m = this.mouse();
+    v1 = ((p = d).fix = pv.vector(d.x, d.y)).minus(m);
+    max = {
+      x: this.parent.width() - (d.dx || 0),
+      y: this.parent.height() - (d.dy || 0)
+    };
+    scene.mark.context(scene, index, function() { this.render(); });
+    pv.Mark.dispatch("dragstart", scene, index);
+  }
+
+  /** @private */
+  function mousemove() {
+    if (!scene) return;
+    scene.mark.context(scene, index, function() {
+        var m = this.mouse();
+        p.x = p.fix.x = Math.max(0, Math.min(v1.x + m.x, max.x));
+        p.y = p.fix.y = Math.max(0, Math.min(v1.y + m.y, max.y));
+        this.render();
+      });
+    pv.Mark.dispatch("drag", scene, index);
+  }
+
+  /** @private */
+  function mouseup() {
+    if (!scene) return;
+    p.fix = null;
+    scene.mark.context(scene, index, function() { this.render(); });
+    pv.Mark.dispatch("dragend", scene, index);
+    scene = null;
+  }
+
+  pv.listen(window, "mousemove", mousemove);
+  pv.listen(window, "mouseup", mouseup);
+  return mousedown;
+};
diff --git a/vendor/protovis/src/behavior/Pan.js b/vendor/protovis/src/behavior/Pan.js
new file mode 100644
index 0000000..d9c50c8
--- /dev/null
+++ b/vendor/protovis/src/behavior/Pan.js
@@ -0,0 +1,110 @@
+/**
+ * Returns a new pan behavior to be registered on mousedown events.
+ *
+ * @class Implements interactive panning starting with mousedown events.
+ * Register this behavior on panels to allow panning. This behavior can be used
+ * in tandem with {@link pv.Behavior.zoom} to allow both panning and zooming:
+ *
+ * <pre>    .event("mousedown", pv.Behavior.pan())
+ *     .event("mousewheel", pv.Behavior.zoom())</pre>
+ *
+ * The pan behavior currently supports only mouse events; support for keyboard
+ * shortcuts to improve accessibility may be added in the future.
+ *
+ * <p>After the initial mousedown event is triggered, this behavior listens for
+ * mousemove and mouseup events on the window. This allows panning to continue
+ * even if the mouse temporarily leaves the panel that is being panned, or even
+ * the root panel.
+ *
+ * <p>The implementation of this behavior relies on the panel's
+ * <tt>transform</tt> property, which specifies a matrix transformation that is
+ * applied to child marks. Note that the transform property only affects the
+ * panel's children, but not the panel itself; therefore the panel's fill and
+ * stroke will not change when the contents are panned.
+ *
+ * <p>Panels have transparent fill styles by default; this means that panels may
+ * not receive the initial mousedown event to start panning. To fix this
+ * problem, either given the panel a visible fill style (such as "white"), or
+ * set the <tt>events</tt> property to "all" such that the panel receives events
+ * despite its transparent fill.
+ *
+ * <p>The pan behavior has optional support for bounding. If enabled, the user
+ * will not be able to pan the panel outside of the initial bounds. This feature
+ * is designed to work in conjunction with the zoom behavior; otherwise,
+ * bounding the panel effectively disables all panning.
+ *
+ * @extends pv.Behavior
+ * @see pv.Behavior.zoom
+ * @see pv.Panel#transform
+ */
+pv.Behavior.pan = function() {
+  var scene, // scene context
+      index, // scene context
+      m1, // transformation matrix at the start of panning
+      v1, // mouse location at the start of panning
+      k, // inverse scale
+      bound; // whether to bound to the panel
+
+  /** @private */
+  function mousedown() {
+    index = this.index;
+    scene = this.scene;
+    v1 = pv.vector(pv.event.pageX, pv.event.pageY);
+    m1 = this.transform();
+    k = 1 / (m1.k * this.scale);
+    if (bound) {
+      bound = {
+        x: (1 - m1.k) * this.width(),
+        y: (1 - m1.k) * this.height()
+      };
+    }
+  }
+
+  /** @private */
+  function mousemove() {
+    if (!scene) return;
+    scene.mark.context(scene, index, function() {
+        var x = (pv.event.pageX - v1.x) * k,
+            y = (pv.event.pageY - v1.y) * k,
+            m = m1.translate(x, y);
+        if (bound) {
+          m.x = Math.max(bound.x, Math.min(0, m.x));
+          m.y = Math.max(bound.y, Math.min(0, m.y));
+        }
+        this.transform(m).render();
+      });
+    pv.Mark.dispatch("pan", scene, index);
+  }
+
+  /** @private */
+  function mouseup() {
+    scene = null;
+  }
+
+  /**
+   * Sets or gets the bound parameter. If bounding is enabled, the user will not
+   * be able to pan outside the initial panel bounds; this typically applies
+   * only when the pan behavior is used in tandem with the zoom behavior.
+   * Bounding is not enabled by default.
+   *
+   * <p>Note: enabling bounding after panning has already occurred will not
+   * immediately reset the transform. Bounding should be enabled before the
+   * panning behavior is applied.
+   *
+   * @function
+   * @returns {pv.Behavior.pan} this, or the current bound parameter.
+   * @name pv.Behavior.pan.prototype.bound
+   * @param {boolean} [x] the new bound parameter.
+   */
+  mousedown.bound = function(x) {
+    if (arguments.length) {
+      bound = Boolean(x);
+      return this;
+    }
+    return Boolean(bound);
+  };
+
+  pv.listen(window, "mousemove", mousemove);
+  pv.listen(window, "mouseup", mouseup);
+  return mousedown;
+};
diff --git a/vendor/protovis/src/behavior/Point.js b/vendor/protovis/src/behavior/Point.js
new file mode 100644
index 0000000..566c3be
--- /dev/null
+++ b/vendor/protovis/src/behavior/Point.js
@@ -0,0 +1,157 @@
+/**
+ * Returns a new point behavior to be registered on mousemove events.
+ *
+ * @class Implements interactive fuzzy pointing, identifying marks that are in
+ * close proximity to the mouse cursor. This behavior is an alternative to the
+ * native mouseover and mouseout events, improving usability. Rather than
+ * requiring the user to mouseover a mark exactly, the mouse simply needs to
+ * move near the given mark and a "point" event is triggered. In addition, if
+ * multiple marks overlap, the point behavior can be used to identify the mark
+ * instance closest to the cursor, as opposed to the one that is rendered on
+ * top.
+ *
+ * <p>The point behavior can also identify the closest mark instance for marks
+ * that produce a continuous graphic primitive. The point behavior can thus be
+ * used to provide details-on-demand for both discrete marks (such as dots and
+ * bars), as well as continuous marks (such as lines and areas).
+ *
+ * <p>This behavior is implemented by finding the closest mark instance to the
+ * mouse cursor on every mousemove event. If this closest mark is within the
+ * given radius threshold, which defaults to 30 pixels, a "point" psuedo-event
+ * is dispatched to the given mark instance. If any mark were previously
+ * pointed, it would receive a corresponding "unpoint" event. These two
+ * psuedo-event types correspond to the native "mouseover" and "mouseout"
+ * events, respectively. To increase the radius at which the point behavior can
+ * be applied, specify an appropriate threshold to the constructor, up to
+ * <tt>Infinity</tt>.
+ *
+ * <p>By default, the standard Cartesian distance is computed. However, with
+ * some visualizations it is desirable to consider only a single dimension, such
+ * as the <i>x</i>-dimension for an independent variable. In this case, the
+ * collapse parameter can be set to collapse the <i>y</i> dimension:
+ *
+ * <pre>    .event("mousemove", pv.Behavior.point(Infinity).collapse("y"))</pre>
+ *
+ * <p>This behavior only listens to mousemove events on the assigned panel,
+ * which is typically the root panel. The behavior will search recursively for
+ * descendant marks to point. If the mouse leaves the assigned panel, the
+ * behavior no longer receives mousemove events; an unpoint psuedo-event is
+ * automatically dispatched to unpoint any pointed mark. Marks may be re-pointed
+ * when the mouse reenters the panel.
+ *
+ * <p>Panels have transparent fill styles by default; this means that panels may
+ * not receive the initial mousemove event to start pointing. To fix this
+ * problem, either given the panel a visible fill style (such as "white"), or
+ * set the <tt>events</tt> property to "all" such that the panel receives events
+ * despite its transparent fill.
+ *
+ * <p>Note: this behavior does not currently wedge marks.
+ *
+ * @extends pv.Behavior
+ *
+ * @param {number} [r] the fuzzy radius threshold in pixels
+ * @see <a href="http://www.tovigrossman.com/papers/chi2005bubblecursor.pdf"
+ * >"The Bubble Cursor: Enhancing Target Acquisition by Dynamic Resizing of the
+ * Cursor's Activation Area"</a> by T. Grossman & R. Balakrishnan, CHI 2005.
+ */
+pv.Behavior.point = function(r) {
+  var unpoint, // the current pointer target
+      collapse = null, // dimensions to collapse
+      kx = 1, // x-dimension cost scale
+      ky = 1, // y-dimension cost scale
+      r2 = arguments.length ? r * r : 900; // fuzzy radius
+
+  /** @private Search for the mark closest to the mouse. */
+  function search(scene, index) {
+    var s = scene[index],
+        point = {cost: Infinity};
+    for (var i = 0, n = s.visible && s.children.length; i < n; i++) {
+      var child = s.children[i], mark = child.mark, p;
+      if (mark.type == "panel") {
+        mark.scene = child;
+        for (var j = 0, m = child.length; j < m; j++) {
+          mark.index = j;
+          p = search(child, j);
+          if (p.cost < point.cost) point = p;
+        }
+        delete mark.scene;
+        delete mark.index;
+      } else if (mark.$handlers.point) {
+        var v = mark.mouse();
+        for (var j = 0, m = child.length; j < m; j++) {
+          var c = child[j],
+              dx = v.x - c.left - (c.width || 0) / 2,
+              dy = v.y - c.top - (c.height || 0) / 2,
+              dd = kx * dx * dx + ky * dy * dy;
+          if (dd < point.cost) {
+            point.distance = dx * dx + dy * dy;
+            point.cost = dd;
+            point.scene = child;
+            point.index = j;
+          }
+        }
+      }
+    }
+    return point;
+  }
+
+  /** @private */
+  function mousemove() {
+    /* If the closest mark is far away, clear the current target. */
+    var point = search(this.scene, this.index);
+    if ((point.cost == Infinity) || (point.distance > r2)) point = null;
+
+    /* Unpoint the old target, if it's not the new target. */
+    if (unpoint) {
+      if (point
+          && (unpoint.scene == point.scene)
+          && (unpoint.index == point.index)) return;
+      pv.Mark.dispatch("unpoint", unpoint.scene, unpoint.index);
+    }
+
+    /* Point the new target, if there is one. */
+    if (unpoint = point) {
+      pv.Mark.dispatch("point", point.scene, point.index);
+
+      /* Unpoint when the mouse leaves the root panel. */
+      pv.listen(this.root.canvas(), "mouseout", mouseout);
+    }
+  }
+
+  /** @private */
+  function mouseout(e) {
+    if (unpoint && !pv.ancestor(this, e.relatedTarget)) {
+      pv.Mark.dispatch("unpoint", unpoint.scene, unpoint.index);
+      unpoint = null;
+    }
+  }
+
+  /**
+   * Sets or gets the collapse parameter. By default, the standard Cartesian
+   * distance is computed. However, with some visualizations it is desirable to
+   * consider only a single dimension, such as the <i>x</i>-dimension for an
+   * independent variable. In this case, the collapse parameter can be set to
+   * collapse the <i>y</i> dimension:
+   *
+   * <pre>    .event("mousemove", pv.Behavior.point(Infinity).collapse("y"))</pre>
+   *
+   * @function
+   * @returns {pv.Behavior.point} this, or the current collapse parameter.
+   * @name pv.Behavior.point.prototype.collapse
+   * @param {string} [x] the new collapse parameter
+   */
+  mousemove.collapse = function(x) {
+    if (arguments.length) {
+      collapse = String(x);
+      switch (collapse) {
+        case "y": kx = 1; ky = 0; break;
+        case "x": kx = 0; ky = 1; break;
+        default: kx = 1; ky = 1; break;
+      }
+      return mousemove;
+    }
+    return collapse;
+  };
+
+  return mousemove;
+};
diff --git a/vendor/protovis/src/behavior/Resize.js b/vendor/protovis/src/behavior/Resize.js
new file mode 100644
index 0000000..0a10f66
--- /dev/null
+++ b/vendor/protovis/src/behavior/Resize.js
@@ -0,0 +1,104 @@
+/**
+ * Returns a new resize behavior to be registered on mousedown events.
+ *
+ * @class Implements interactive resizing of a selection starting with mousedown
+ * events. Register this behavior on selection handles that should be resizeable
+ * by the user, such for brushing and linking. This behavior can be used in
+ * tandom with {@link pv.Behavior.select} and {@link pv.Behavior.drag} to allow
+ * the selected region to be selected and dragged interactively.
+ *
+ * <p>After the initial mousedown event is triggered, this behavior listens for
+ * mousemove and mouseup events on the window. This allows resizing to continue
+ * even if the mouse temporarily leaves the assigned panel, or even the root
+ * panel.
+ *
+ * <p>This behavior requires that the data associated with the mark being
+ * resized have <tt>x</tt>, <tt>y</tt>, <tt>dx</tt> and <tt>dy</tt> attributes
+ * that correspond to the mark's location and dimensions in pixels. The mark's
+ * positional properties are not set directly by this behavior; instead, the
+ * positional properties should be defined as:
+ *
+ * <pre>    .left(function(d) d.x)
+ *     .top(function(d) d.y)
+ *     .width(function(d) d.dx)
+ *     .height(function(d) d.dy)</pre>
+ *
+ * Thus, the behavior does not resize the mark directly, but instead updates the
+ * size by updating the assigned panel's underlying data. Note that if the
+ * positional properties are defined with bottom and right (rather than top and
+ * left), the resize behavior will be inverted, which will confuse users!
+ *
+ * <p>The resize behavior is bounded by the assigned mark's enclosing panel; the
+ * positional attributes are clamped such that the selection does not extend
+ * outside the panel's bounds.
+ *
+ * <p>The mark being resized is automatically re-rendered for each mouse event
+ * as part of the resize operation. This behavior may be enhanced in the future
+ * to allow more flexible configuration. In some cases, such as with parallel
+ * coordinates, resizing the selection may cause related marks to change, in
+ * which case additional marks may also need to be rendered. This can be
+ * accomplished by listening for the select psuedo-events:<ul>
+ *
+ * <li>resizestart (on mousedown)
+ * <li>resize (on mousemove)
+ * <li>resizeend (on mouseup)
+ *
+ * </ul>For example, to render the parent panel while resizing, thus
+ * re-rendering all sibling marks:
+ *
+ * <pre>    .event("mousedown", pv.Behavior.resize("left"))
+ *     .event("resize", function() this.parent)</pre>
+ *
+ * This behavior may be enhanced in the future to allow more flexible
+ * configuration of the selection behavior.
+ *
+ * @extends pv.Behavior
+ * @see pv.Behavior.select
+ * @see pv.Behavior.drag
+ */
+pv.Behavior.resize = function(side) {
+  var scene, // scene context
+      index, // scene context
+      r, // region being selected
+      m1; // initial mouse position
+
+  /** @private */
+  function mousedown(d) {
+    index = this.index;
+    scene = this.scene;
+    m1 = this.mouse();
+    r = d;
+    switch (side) {
+      case "left": m1.x = r.x + r.dx; break;
+      case "right": m1.x = r.x; break;
+      case "top": m1.y = r.y + r.dy; break;
+      case "bottom": m1.y = r.y; break;
+    }
+    pv.Mark.dispatch("resizestart", scene, index);
+  }
+
+  /** @private */
+  function mousemove() {
+    if (!scene) return;
+    scene.mark.context(scene, index, function() {
+        var m2 = this.mouse();
+        r.x = Math.max(0, Math.min(m1.x, m2.x));
+        r.y = Math.max(0, Math.min(m1.y, m2.y));
+        r.dx = Math.min(this.parent.width(), Math.max(m2.x, m1.x)) - r.x;
+        r.dy = Math.min(this.parent.height(), Math.max(m2.y, m1.y)) - r.y;
+        this.render();
+      });
+    pv.Mark.dispatch("resize", scene, index);
+  }
+
+  /** @private */
+  function mouseup() {
+    if (!scene) return;
+    pv.Mark.dispatch("resizeend", scene, index);
+    scene = null;
+  }
+
+  pv.listen(window, "mousemove", mousemove);
+  pv.listen(window, "mouseup", mouseup);
+  return mousedown;
+};
diff --git a/vendor/protovis/src/behavior/Select.js b/vendor/protovis/src/behavior/Select.js
new file mode 100644
index 0000000..148254f
--- /dev/null
+++ b/vendor/protovis/src/behavior/Select.js
@@ -0,0 +1,100 @@
+/**
+ * Returns a new select behavior to be registered on mousedown events.
+ *
+ * @class Implements interactive selecting starting with mousedown events.
+ * Register this behavior on panels that should be selectable by the user, such
+ * for brushing and linking. This behavior can be used in tandom with
+ * {@link pv.Behavior.drag} to allow the selected region to be dragged
+ * interactively.
+ *
+ * <p>After the initial mousedown event is triggered, this behavior listens for
+ * mousemove and mouseup events on the window. This allows selecting to continue
+ * even if the mouse temporarily leaves the assigned panel, or even the root
+ * panel.
+ *
+ * <p>This behavior requires that the data associated with the mark being
+ * dragged have <tt>x</tt>, <tt>y</tt>, <tt>dx</tt> and <tt>dy</tt> attributes
+ * that correspond to the mark's location and dimensions in pixels. The mark's
+ * positional properties are not set directly by this behavior; instead, the
+ * positional properties should be defined as:
+ *
+ * <pre>    .left(function(d) d.x)
+ *     .top(function(d) d.y)
+ *     .width(function(d) d.dx)
+ *     .height(function(d) d.dy)</pre>
+ *
+ * Thus, the behavior does not resize the mark directly, but instead updates the
+ * selection by updating the assigned panel's underlying data. Note that if the
+ * positional properties are defined with bottom and right (rather than top and
+ * left), the drag behavior will be inverted, which will confuse users!
+ *
+ * <p>The select behavior is bounded by the assigned panel; the positional
+ * attributes are clamped such that the selection does not extend outside the
+ * panel's bounds.
+ *
+ * <p>The panel being selected is automatically re-rendered for each mouse event
+ * as part of the drag operation. This behavior may be enhanced in the future to
+ * allow more flexible configuration of select behavior. In some cases, such as
+ * with parallel coordinates, making a selection may cause related marks to
+ * change, in which case additional marks may also need to be rendered. This can
+ * be accomplished by listening for the select psuedo-events:<ul>
+ *
+ * <li>selectstart (on mousedown)
+ * <li>select (on mousemove)
+ * <li>selectend (on mouseup)
+ *
+ * </ul>For example, to render the parent panel while selecting, thus
+ * re-rendering all sibling marks:
+ *
+ * <pre>    .event("mousedown", pv.Behavior.drag())
+ *     .event("select", function() this.parent)</pre>
+ *
+ * This behavior may be enhanced in the future to allow more flexible
+ * configuration of the selection behavior.
+ *
+ * @extends pv.Behavior
+ * @see pv.Behavior.drag
+ */
+pv.Behavior.select = function() {
+  var scene, // scene context
+      index, // scene context
+      r, // region being selected
+      m1; // initial mouse position
+
+  /** @private */
+  function mousedown(d) {
+    index = this.index;
+    scene = this.scene;
+    m1 = this.mouse();
+    r = d;
+    r.x = m1.x;
+    r.y = m1.y;
+    r.dx = r.dy = 0;
+    pv.Mark.dispatch("selectstart", scene, index);
+  }
+
+  /** @private */
+  function mousemove() {
+    if (!scene) return;
+    scene.mark.context(scene, index, function() {
+        var m2 = this.mouse();
+        r.x = Math.max(0, Math.min(m1.x, m2.x));
+        r.y = Math.max(0, Math.min(m1.y, m2.y));
+        r.dx = Math.min(this.width(), Math.max(m2.x, m1.x)) - r.x;
+        r.dy = Math.min(this.height(), Math.max(m2.y, m1.y)) - r.y;
+        this.render();
+      });
+    pv.Mark.dispatch("select", scene, index);
+  }
+
+  /** @private */
+  function mouseup() {
+    if (!scene) return;
+    pv.Mark.dispatch("selectend", scene, index);
+    scene = null;
+  }
+
+  pv.listen(window, "mousemove", mousemove);
+  pv.listen(window, "mouseup", mouseup);
+  return mousedown;
+};
diff --git a/vendor/protovis/src/behavior/Zoom.js b/vendor/protovis/src/behavior/Zoom.js
new file mode 100644
index 0000000..3a185b4
--- /dev/null
+++ b/vendor/protovis/src/behavior/Zoom.js
@@ -0,0 +1,85 @@
+/**
+ * Returns a new zoom behavior to be registered on mousewheel events.
+ *
+ * @class Implements interactive zooming using mousewheel events. Register this
+ * behavior on panels to allow zooming. This behavior can be used in tandem with
+ * {@link pv.Behavior.pan} to allow both panning and zooming:
+ *
+ * <pre>    .event("mousedown", pv.Behavior.pan())
+ *     .event("mousewheel", pv.Behavior.zoom())</pre>
+ *
+ * The zoom behavior currently supports only mousewheel events; support for
+ * keyboard shortcuts and gesture events to improve accessibility may be added
+ * in the future.
+ *
+ * <p>The implementation of this behavior relies on the panel's
+ * <tt>transform</tt> property, which specifies a matrix transformation that is
+ * applied to child marks. Note that the transform property only affects the
+ * panel's children, but not the panel itself; therefore the panel's fill and
+ * stroke will not change when the contents are zoomed. The built-in support for
+ * transforms only supports uniform scaling and translates, which is sufficient
+ * for panning and zooming.  Note that this is not a strict geometric
+ * transformation, as the <tt>lineWidth</tt> property is scale-aware: strokes
+ * are drawn at constant size independent of scale.
+ *
+ * <p>Panels have transparent fill styles by default; this means that panels may
+ * not receive mousewheel events to zoom. To fix this problem, either given the
+ * panel a visible fill style (such as "white"), or set the <tt>events</tt>
+ * property to "all" such that the panel receives events despite its transparent
+ * fill.
+ *
+ * <p>The zoom behavior has optional support for bounding. If enabled, the user
+ * will not be able to zoom out farther than the initial bounds. This feature is
+ * designed to work in conjunction with the pan behavior.
+ *
+ * @extends pv.Behavior
+ * @see pv.Panel#transform
+ * @see pv.Mark#scale
+ * @param {number} speed
+ */
+pv.Behavior.zoom = function(speed) {
+  var bound; // whether to bound to the panel
+
+  if (!arguments.length) speed = 1 / 48;
+
+  /** @private */
+  function mousewheel() {
+    var v = this.mouse(),
+        k = pv.event.wheel * speed,
+        m = this.transform().translate(v.x, v.y)
+            .scale((k < 0) ? (1e3 / (1e3 - k)) : ((1e3 + k) / 1e3))
+            .translate(-v.x, -v.y);
+    if (bound) {
+      m.k = Math.max(1, m.k);
+      m.x = Math.max((1 - m.k) * this.width(), Math.min(0, m.x));
+      m.y = Math.max((1 - m.k) * this.height(), Math.min(0, m.y));
+    }
+    this.transform(m).render();
+    pv.Mark.dispatch("zoom", this.scene, this.index);
+  }
+
+  /**
+   * Sets or gets the bound parameter. If bounding is enabled, the user will not
+   * be able to zoom out farther than the initial panel bounds. Bounding is not
+   * enabled by default. If this behavior is used in tandem with the pan
+   * behavior, both should use the same bound parameter.
+   *
+   * <p>Note: enabling bounding after zooming has already occurred will not
+   * immediately reset the transform. Bounding should be enabled before the zoom
+   * behavior is applied.
+   *
+   * @function
+   * @returns {pv.Behavior.zoom} this, or the current bound parameter.
+   * @name pv.Behavior.zoom.prototype.bound
+   * @param {boolean} [x] the new bound parameter.
+   */
+  mousewheel.bound = function(x) {
+    if (arguments.length) {
+      bound = Boolean(x);
+      return this;
+    }
+    return Boolean(bound);
+  };
+
+  return mousewheel;
+};
diff --git a/vendor/protovis/src/color/Color.js b/vendor/protovis/src/color/Color.js
new file mode 100644
index 0000000..c6f4437
--- /dev/null
+++ b/vendor/protovis/src/color/Color.js
@@ -0,0 +1,598 @@
+/**
+ * Returns the {@link pv.Color} for the specified color format string. Colors
+ * may have an associated opacity, or alpha channel. Color formats are specified
+ * by CSS Color Modular Level 3, using either in RGB or HSL color space. For
+ * example:<ul>
+ *
+ * <li>#f00 // #rgb
+ * <li>#ff0000 // #rrggbb
+ * <li>rgb(255, 0, 0)
+ * <li>rgb(100%, 0%, 0%)
+ * <li>hsl(0, 100%, 50%)
+ * <li>rgba(0, 0, 255, 0.5)
+ * <li>hsla(120, 100%, 50%, 1)
+ *
+ * </ul>The SVG 1.0 color keywords names are also supported, such as "aliceblue"
+ * and "yellowgreen". The "transparent" keyword is supported for fully-
+ * transparent black.
+ *
+ * <p>If the <tt>format</tt> argument is already an instance of <tt>Color</tt>,
+ * the argument is returned with no further processing.
+ *
+ * @param {string} format the color specification string, such as "#f00".
+ * @returns {pv.Color} the corresponding <tt>Color</tt>.
+ * @see <a href="http://www.w3.org/TR/SVG/types.html#ColorKeywords">SVG color
+ * keywords</a>
+ * @see <a href="http://www.w3.org/TR/css3-color/">CSS3 color module</a>
+ */
+pv.color = function(format) {
+  if (format.rgb) return format.rgb();
+
+  /* Handle hsl, rgb. */
+  var m1 = /([a-z]+)\((.*)\)/i.exec(format);
+  if (m1) {
+    var m2 = m1[2].split(","), a = 1;
+    switch (m1[1]) {
+      case "hsla":
+      case "rgba": {
+        a = parseFloat(m2[3]);
+        if (!a) return pv.Color.transparent;
+        break;
+      }
+    }
+    switch (m1[1]) {
+      case "hsla":
+      case "hsl": {
+        var h = parseFloat(m2[0]), // degrees
+            s = parseFloat(m2[1]) / 100, // percentage
+            l = parseFloat(m2[2]) / 100; // percentage
+        return (new pv.Color.Hsl(h, s, l, a)).rgb();
+      }
+      case "rgba":
+      case "rgb": {
+        function parse(c) { // either integer or percentage
+          var f = parseFloat(c);
+          return (c[c.length - 1] == '%') ? Math.round(f * 2.55) : f;
+        }
+        var r = parse(m2[0]), g = parse(m2[1]), b = parse(m2[2]);
+        return pv.rgb(r, g, b, a);
+      }
+    }
+  }
+
+  /* Named colors. */
+  var named = pv.Color.names[format];
+  if (named) return named;
+
+  /* Hexadecimal colors: #rgb and #rrggbb. */
+  if (format.charAt(0) == "#") {
+    var r, g, b;
+    if (format.length == 4) {
+      r = format.charAt(1); r += r;
+      g = format.charAt(2); g += g;
+      b = format.charAt(3); b += b;
+    } else if (format.length == 7) {
+      r = format.substring(1, 3);
+      g = format.substring(3, 5);
+      b = format.substring(5, 7);
+    }
+    return pv.rgb(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), 1);
+  }
+
+  /* Otherwise, pass-through unsupported colors. */
+  return new pv.Color(format, 1);
+};
+
+/**
+ * Constructs a color with the specified color format string and opacity. This
+ * constructor should not be invoked directly; use {@link pv.color} instead.
+ *
+ * @class Represents an abstract (possibly translucent) color. The color is
+ * divided into two parts: the <tt>color</tt> attribute, an opaque color format
+ * string, and the <tt>opacity</tt> attribute, a float in [0, 1]. The color
+ * space is dependent on the implementing class; all colors support the
+ * {@link #rgb} method to convert to RGB color space for interpolation.
+ *
+ * <p>See also the <a href="../../api/Color.html">Color guide</a>.
+ *
+ * @param {string} color an opaque color format string, such as "#f00".
+ * @param {number} opacity the opacity, in [0,1].
+ * @see pv.color
+ */
+pv.Color = function(color, opacity) {
+  /**
+   * An opaque color format string, such as "#f00".
+   *
+   * @type string
+   * @see <a href="http://www.w3.org/TR/SVG/types.html#ColorKeywords">SVG color
+   * keywords</a>
+   * @see <a href="http://www.w3.org/TR/css3-color/">CSS3 color module</a>
+   */
+  this.color = color;
+
+  /**
+   * The opacity, a float in [0, 1].
+   *
+   * @type number
+   */
+  this.opacity = opacity;
+};
+
+/**
+ * Returns a new color that is a brighter version of this color. The behavior of
+ * this method may vary slightly depending on the underlying color space.
+ * Although brighter and darker are inverse operations, the results of a series
+ * of invocations of these two methods might be inconsistent because of rounding
+ * errors.
+ *
+ * @param [k] {number} an optional scale factor; defaults to 1.
+ * @see #darker
+ * @returns {pv.Color} a brighter color.
+ */
+pv.Color.prototype.brighter = function(k) {
+  return this.rgb().brighter(k);
+};
+
+/**
+ * Returns a new color that is a brighter version of this color. The behavior of
+ * this method may vary slightly depending on the underlying color space.
+ * Although brighter and darker are inverse operations, the results of a series
+ * of invocations of these two methods might be inconsistent because of rounding
+ * errors.
+ *
+ * @param [k] {number} an optional scale factor; defaults to 1.
+ * @see #brighter
+ * @returns {pv.Color} a darker color.
+ */
+pv.Color.prototype.darker = function(k) {
+  return this.rgb().darker(k);
+};
+
+/**
+ * Constructs a new RGB color with the specified channel values.
+ *
+ * @param {number} r the red channel, an integer in [0,255].
+ * @param {number} g the green channel, an integer in [0,255].
+ * @param {number} b the blue channel, an integer in [0,255].
+ * @param {number} [a] the alpha channel, a float in [0,1].
+ * @returns pv.Color.Rgb
+ */
+pv.rgb = function(r, g, b, a) {
+  return new pv.Color.Rgb(r, g, b, (arguments.length == 4) ? a : 1);
+};
+
+/**
+ * Constructs a new RGB color with the specified channel values.
+ *
+ * @class Represents a color in RGB space.
+ *
+ * @param {number} r the red channel, an integer in [0,255].
+ * @param {number} g the green channel, an integer in [0,255].
+ * @param {number} b the blue channel, an integer in [0,255].
+ * @param {number} a the alpha channel, a float in [0,1].
+ * @extends pv.Color
+ */
+pv.Color.Rgb = function(r, g, b, a) {
+  pv.Color.call(this, a ? ("rgb(" + r + "," + g + "," + b + ")") : "none", a);
+
+  /**
+   * The red channel, an integer in [0, 255].
+   *
+   * @type number
+   */
+  this.r = r;
+
+  /**
+   * The green channel, an integer in [0, 255].
+   *
+   * @type number
+   */
+  this.g = g;
+
+  /**
+   * The blue channel, an integer in [0, 255].
+   *
+   * @type number
+   */
+  this.b = b;
+
+  /**
+   * The alpha channel, a float in [0, 1].
+   *
+   * @type number
+   */
+  this.a = a;
+};
+pv.Color.Rgb.prototype = pv.extend(pv.Color);
+
+/**
+ * Constructs a new RGB color with the same green, blue and alpha channels as
+ * this color, with the specified red channel.
+ *
+ * @param {number} r the red channel, an integer in [0,255].
+ */
+pv.Color.Rgb.prototype.red = function(r) {
+  return pv.rgb(r, this.g, this.b, this.a);
+};
+
+/**
+ * Constructs a new RGB color with the same red, blue and alpha channels as this
+ * color, with the specified green channel.
+ *
+ * @param {number} g the green channel, an integer in [0,255].
+ */
+pv.Color.Rgb.prototype.green = function(g) {
+  return pv.rgb(this.r, g, this.b, this.a);
+};
+
+/**
+ * Constructs a new RGB color with the same red, green and alpha channels as
+ * this color, with the specified blue channel.
+ *
+ * @param {number} b the blue channel, an integer in [0,255].
+ */
+pv.Color.Rgb.prototype.blue = function(b) {
+  return pv.rgb(this.r, this.g, b, this.a);
+};
+
+/**
+ * Constructs a new RGB color with the same red, green and blue channels as this
+ * color, with the specified alpha channel.
+ *
+ * @param {number} a the alpha channel, a float in [0,1].
+ */
+pv.Color.Rgb.prototype.alpha = function(a) {
+  return pv.rgb(this.r, this.g, this.b, a);
+};
+
+/**
+ * Returns the RGB color equivalent to this color. This method is abstract and
+ * must be implemented by subclasses.
+ *
+ * @returns {pv.Color.Rgb} an RGB color.
+ * @function
+ * @name pv.Color.prototype.rgb
+ */
+
+/**
+ * Returns this.
+ *
+ * @returns {pv.Color.Rgb} this.
+ */
+pv.Color.Rgb.prototype.rgb = function() { return this; };
+
+/**
+ * Returns a new color that is a brighter version of this color. This method
+ * applies an arbitrary scale factor to each of the three RGB components of this
+ * color to create a brighter version of this color. Although brighter and
+ * darker are inverse operations, the results of a series of invocations of
+ * these two methods might be inconsistent because of rounding errors.
+ *
+ * @param [k] {number} an optional scale factor; defaults to 1.
+ * @see #darker
+ * @returns {pv.Color.Rgb} a brighter color.
+ */
+pv.Color.Rgb.prototype.brighter = function(k) {
+  k = Math.pow(0.7, arguments.length ? k : 1);
+  var r = this.r, g = this.g, b = this.b, i = 30;
+  if (!r && !g && !b) return pv.rgb(i, i, i, this.a);
+  if (r && (r < i)) r = i;
+  if (g && (g < i)) g = i;
+  if (b && (b < i)) b = i;
+  return pv.rgb(
+      Math.min(255, Math.floor(r / k)),
+      Math.min(255, Math.floor(g / k)),
+      Math.min(255, Math.floor(b / k)),
+      this.a);
+};
+
+/**
+ * Returns a new color that is a darker version of this color. This method
+ * applies an arbitrary scale factor to each of the three RGB components of this
+ * color to create a darker version of this color. Although brighter and darker
+ * are inverse operations, the results of a series of invocations of these two
+ * methods might be inconsistent because of rounding errors.
+ *
+ * @param [k] {number} an optional scale factor; defaults to 1.
+ * @see #brighter
+ * @returns {pv.Color.Rgb} a darker color.
+ */
+pv.Color.Rgb.prototype.darker = function(k) {
+  k = Math.pow(0.7, arguments.length ? k : 1);
+  return pv.rgb(
+      Math.max(0, Math.floor(k * this.r)),
+      Math.max(0, Math.floor(k * this.g)),
+      Math.max(0, Math.floor(k * this.b)),
+      this.a);
+};
+
+/**
+ * Constructs a new HSL color with the specified values.
+ *
+ * @param {number} h the hue, an integer in [0, 360].
+ * @param {number} s the saturation, a float in [0, 1].
+ * @param {number} l the lightness, a float in [0, 1].
+ * @param {number} [a] the opacity, a float in [0, 1].
+ * @returns pv.Color.Hsl
+ */
+pv.hsl = function(h, s, l, a) {
+  return new pv.Color.Hsl(h, s, l,  (arguments.length == 4) ? a : 1);
+};
+
+/**
+ * Constructs a new HSL color with the specified values.
+ *
+ * @class Represents a color in HSL space.
+ *
+ * @param {number} h the hue, an integer in [0, 360].
+ * @param {number} s the saturation, a float in [0, 1].
+ * @param {number} l the lightness, a float in [0, 1].
+ * @param {number} a the opacity, a float in [0, 1].
+ * @extends pv.Color
+ */
+pv.Color.Hsl = function(h, s, l, a) {
+  pv.Color.call(this, "hsl(" + h + "," + (s * 100) + "%," + (l * 100) + "%)", a);
+
+  /**
+   * The hue, an integer in [0, 360].
+   *
+   * @type number
+   */
+  this.h = h;
+
+  /**
+   * The saturation, a float in [0, 1].
+   *
+   * @type number
+   */
+  this.s = s;
+
+  /**
+   * The lightness, a float in [0, 1].
+   *
+   * @type number
+   */
+  this.l = l;
+
+  /**
+   * The opacity, a float in [0, 1].
+   *
+   * @type number
+   */
+  this.a = a;
+};
+pv.Color.Hsl.prototype = pv.extend(pv.Color);
+
+/**
+ * Constructs a new HSL color with the same saturation, lightness and alpha as
+ * this color, and the specified hue.
+ *
+ * @param {number} h the hue, an integer in [0, 360].
+ */
+pv.Color.Hsl.prototype.hue = function(h) {
+  return pv.hsl(h, this.s, this.l, this.a);
+};
+
+/**
+ * Constructs a new HSL color with the same hue, lightness and alpha as this
+ * color, and the specified saturation.
+ *
+ * @param {number} s the saturation, a float in [0, 1].
+ */
+pv.Color.Hsl.prototype.saturation = function(s) {
+  return pv.hsl(this.h, s, this.l, this.a);
+};
+
+/**
+ * Constructs a new HSL color with the same hue, saturation and alpha as this
+ * color, and the specified lightness.
+ *
+ * @param {number} l the lightness, a float in [0, 1].
+ */
+pv.Color.Hsl.prototype.lightness = function(l) {
+  return pv.hsl(this.h, this.s, l, this.a);
+};
+
+/**
+ * Constructs a new HSL color with the same hue, saturation and lightness as
+ * this color, and the specified alpha.
+ *
+ * @param {number} a the opacity, a float in [0, 1].
+ */
+pv.Color.Hsl.prototype.alpha = function(a) {
+  return pv.hsl(this.h, this.s, this.l, a);
+};
+
+/**
+ * Returns the RGB color equivalent to this HSL color.
+ *
+ * @returns {pv.Color.Rgb} an RGB color.
+ */
+pv.Color.Hsl.prototype.rgb = function() {
+  var h = this.h, s = this.s, l = this.l;
+
+  /* Some simple corrections for h, s and l. */
+  h = h % 360; if (h < 0) h += 360;
+  s = Math.max(0, Math.min(s, 1));
+  l = Math.max(0, Math.min(l, 1));
+
+  /* From FvD 13.37, CSS Color Module Level 3 */
+  var m2 = (l <= .5) ? (l * (1 + s)) : (l + s - l * s);
+  var m1 = 2 * l - m2;
+  function v(h) {
+    if (h > 360) h -= 360;
+    else if (h < 0) h += 360;
+    if (h < 60) return m1 + (m2 - m1) * h / 60;
+    if (h < 180) return m2;
+    if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60;
+    return m1;
+  }
+  function vv(h) {
+    return Math.round(v(h) * 255);
+  }
+
+  return pv.rgb(vv(h + 120), vv(h), vv(h - 120), this.a);
+};
+
+/**
+ * @private SVG color keywords, per CSS Color Module Level 3.
+ *
+ * @see <a href="http://www.w3.org/TR/SVG/types.html#ColorKeywords">SVG color
+ * keywords</a>
+ */
+pv.Color.names = {
+  aliceblue: "#f0f8ff",
+  antiquewhite: "#faebd7",
+  aqua: "#00ffff",
+  aquamarine: "#7fffd4",
+  azure: "#f0ffff",
+  beige: "#f5f5dc",
+  bisque: "#ffe4c4",
+  black: "#000000",
+  blanchedalmond: "#ffebcd",
+  blue: "#0000ff",
+  blueviolet: "#8a2be2",
+  brown: "#a52a2a",
+  burlywood: "#deb887",
+  cadetblue: "#5f9ea0",
+  chartreuse: "#7fff00",
+  chocolate: "#d2691e",
+  coral: "#ff7f50",
+  cornflowerblue: "#6495ed",
+  cornsilk: "#fff8dc",
+  crimson: "#dc143c",
+  cyan: "#00ffff",
+  darkblue: "#00008b",
+  darkcyan: "#008b8b",
+  darkgoldenrod: "#b8860b",
+  darkgray: "#a9a9a9",
+  darkgreen: "#006400",
+  darkgrey: "#a9a9a9",
+  darkkhaki: "#bdb76b",
+  darkmagenta: "#8b008b",
+  darkolivegreen: "#556b2f",
+  darkorange: "#ff8c00",
+  darkorchid: "#9932cc",
+  darkred: "#8b0000",
+  darksalmon: "#e9967a",
+  darkseagreen: "#8fbc8f",
+  darkslateblue: "#483d8b",
+  darkslategray: "#2f4f4f",
+  darkslategrey: "#2f4f4f",
+  darkturquoise: "#00ced1",
+  darkviolet: "#9400d3",
+  deeppink: "#ff1493",
+  deepskyblue: "#00bfff",
+  dimgray: "#696969",
+  dimgrey: "#696969",
+  dodgerblue: "#1e90ff",
+  firebrick: "#b22222",
+  floralwhite: "#fffaf0",
+  forestgreen: "#228b22",
+  fuchsia: "#ff00ff",
+  gainsboro: "#dcdcdc",
+  ghostwhite: "#f8f8ff",
+  gold: "#ffd700",
+  goldenrod: "#daa520",
+  gray: "#808080",
+  green: "#008000",
+  greenyellow: "#adff2f",
+  grey: "#808080",
+  honeydew: "#f0fff0",
+  hotpink: "#ff69b4",
+  indianred: "#cd5c5c",
+  indigo: "#4b0082",
+  ivory: "#fffff0",
+  khaki: "#f0e68c",
+  lavender: "#e6e6fa",
+  lavenderblush: "#fff0f5",
+  lawngreen: "#7cfc00",
+  lemonchiffon: "#fffacd",
+  lightblue: "#add8e6",
+  lightcoral: "#f08080",
+  lightcyan: "#e0ffff",
+  lightgoldenrodyellow: "#fafad2",
+  lightgray: "#d3d3d3",
+  lightgreen: "#90ee90",
+  lightgrey: "#d3d3d3",
+  lightpink: "#ffb6c1",
+  lightsalmon: "#ffa07a",
+  lightseagreen: "#20b2aa",
+  lightskyblue: "#87cefa",
+  lightslategray: "#778899",
+  lightslategrey: "#778899",
+  lightsteelblue: "#b0c4de",
+  lightyellow: "#ffffe0",
+  lime: "#00ff00",
+  limegreen: "#32cd32",
+  linen: "#faf0e6",
+  magenta: "#ff00ff",
+  maroon: "#800000",
+  mediumaquamarine: "#66cdaa",
+  mediumblue: "#0000cd",
+  mediumorchid: "#ba55d3",
+  mediumpurple: "#9370db",
+  mediumseagreen: "#3cb371",
+  mediumslateblue: "#7b68ee",
+  mediumspringgreen: "#00fa9a",
+  mediumturquoise: "#48d1cc",
+  mediumvioletred: "#c71585",
+  midnightblue: "#191970",
+  mintcream: "#f5fffa",
+  mistyrose: "#ffe4e1",
+  moccasin: "#ffe4b5",
+  navajowhite: "#ffdead",
+  navy: "#000080",
+  oldlace: "#fdf5e6",
+  olive: "#808000",
+  olivedrab: "#6b8e23",
+  orange: "#ffa500",
+  orangered: "#ff4500",
+  orchid: "#da70d6",
+  palegoldenrod: "#eee8aa",
+  palegreen: "#98fb98",
+  paleturquoise: "#afeeee",
+  palevioletred: "#db7093",
+  papayawhip: "#ffefd5",
+  peachpuff: "#ffdab9",
+  peru: "#cd853f",
+  pink: "#ffc0cb",
+  plum: "#dda0dd",
+  powderblue: "#b0e0e6",
+  purple: "#800080",
+  red: "#ff0000",
+  rosybrown: "#bc8f8f",
+  royalblue: "#4169e1",
+  saddlebrown: "#8b4513",
+  salmon: "#fa8072",
+  sandybrown: "#f4a460",
+  seagreen: "#2e8b57",
+  seashell: "#fff5ee",
+  sienna: "#a0522d",
+  silver: "#c0c0c0",
+  skyblue: "#87ceeb",
+  slateblue: "#6a5acd",
+  slategray: "#708090",
+  slategrey: "#708090",
+  snow: "#fffafa",
+  springgreen: "#00ff7f",
+  steelblue: "#4682b4",
+  tan: "#d2b48c",
+  teal: "#008080",
+  thistle: "#d8bfd8",
+  tomato: "#ff6347",
+  turquoise: "#40e0d0",
+  violet: "#ee82ee",
+  wheat: "#f5deb3",
+  white: "#ffffff",
+  whitesmoke: "#f5f5f5",
+  yellow: "#ffff00",
+  yellowgreen: "#9acd32",
+  transparent: pv.Color.transparent = pv.rgb(0, 0, 0, 0)
+};
+
+/* Initialized named colors. */
+(function() {
+  var names = pv.Color.names;
+  for (var name in names) names[name] = pv.color(names[name]);
+})();
diff --git a/vendor/protovis/src/color/Colors.js b/vendor/protovis/src/color/Colors.js
new file mode 100644
index 0000000..ae70f5f
--- /dev/null
+++ b/vendor/protovis/src/color/Colors.js
@@ -0,0 +1,135 @@
+/**
+ * Returns a new categorical color encoding using the specified colors.  The
+ * arguments to this method are an array of colors; see {@link pv.color}. For
+ * example, to create a categorical color encoding using the <tt>species</tt>
+ * attribute:
+ *
+ * <pre>pv.colors("red", "green", "blue").by(function(d) d.species)</pre>
+ *
+ * The result of this expression can be used as a fill- or stroke-style
+ * property. This assumes that the data's <tt>species</tt> attribute is a
+ * string.
+ *
+ * @param {string} colors... categorical colors.
+ * @see pv.Scale.ordinal
+ * @returns {pv.Scale.ordinal} an ordinal color scale.
+ */
+pv.colors = function() {
+  var scale = pv.Scale.ordinal();
+  scale.range.apply(scale, arguments);
+  return scale;
+};
+
+/**
+ * A collection of standard color palettes for categorical encoding.
+ *
+ * @namespace A collection of standard color palettes for categorical encoding.
+ */
+pv.Colors = {};
+
+/**
+ * Returns a new 10-color scheme. The arguments to this constructor are
+ * optional, and equivalent to calling {@link pv.Scale.OrdinalScale#domain}. The
+ * following colors are used:
+ *
+ * <div style="background:#1f77b4;">#1f77b4</div>
+ * <div style="background:#ff7f0e;">#ff7f0e</div>
+ * <div style="background:#2ca02c;">#2ca02c</div>
+ * <div style="background:#d62728;">#d62728</div>
+ * <div style="background:#9467bd;">#9467bd</div>
+ * <div style="background:#8c564b;">#8c564b</div>
+ * <div style="background:#e377c2;">#e377c2</div>
+ * <div style="background:#7f7f7f;">#7f7f7f</div>
+ * <div style="background:#bcbd22;">#bcbd22</div>
+ * <div style="background:#17becf;">#17becf</div>
+ *
+ * @param {number...} domain... domain values.
+ * @returns {pv.Scale.ordinal} a new ordinal color scale.
+ * @see pv.color
+ */
+pv.Colors.category10 = function() {
+  var scale = pv.colors(
+      "#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd",
+      "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf");
+  scale.domain.apply(scale, arguments);
+  return scale;
+};
+
+/**
+ * Returns a new 20-color scheme. The arguments to this constructor are
+ * optional, and equivalent to calling {@link pv.Scale.OrdinalScale#domain}. The
+ * following colors are used:
+ *
+ * <div style="background:#1f77b4;">#1f77b4</div>
+ * <div style="background:#aec7e8;">#aec7e8</div>
+ * <div style="background:#ff7f0e;">#ff7f0e</div>
+ * <div style="background:#ffbb78;">#ffbb78</div>
+ * <div style="background:#2ca02c;">#2ca02c</div>
+ * <div style="background:#98df8a;">#98df8a</div>
+ * <div style="background:#d62728;">#d62728</div>
+ * <div style="background:#ff9896;">#ff9896</div>
+ * <div style="background:#9467bd;">#9467bd</div>
+ * <div style="background:#c5b0d5;">#c5b0d5</div>
+ * <div style="background:#8c564b;">#8c564b</div>
+ * <div style="background:#c49c94;">#c49c94</div>
+ * <div style="background:#e377c2;">#e377c2</div>
+ * <div style="background:#f7b6d2;">#f7b6d2</div>
+ * <div style="background:#7f7f7f;">#7f7f7f</div>
+ * <div style="background:#c7c7c7;">#c7c7c7</div>
+ * <div style="background:#bcbd22;">#bcbd22</div>
+ * <div style="background:#dbdb8d;">#dbdb8d</div>
+ * <div style="background:#17becf;">#17becf</div>
+ * <div style="background:#9edae5;">#9edae5</div>
+ *
+ * @param {number...} domain... domain values.
+ * @returns {pv.Scale.ordinal} a new ordinal color scale.
+ * @see pv.color
+*/
+pv.Colors.category20 = function() {
+  var scale = pv.colors(
+      "#1f77b4", "#aec7e8", "#ff7f0e", "#ffbb78", "#2ca02c",
+      "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5",
+      "#8c564b", "#c49c94", "#e377c2", "#f7b6d2", "#7f7f7f",
+      "#c7c7c7", "#bcbd22", "#dbdb8d", "#17becf", "#9edae5");
+  scale.domain.apply(scale, arguments);
+  return scale;
+};
+
+/**
+ * Returns a new alternative 19-color scheme. The arguments to this constructor
+ * are optional, and equivalent to calling
+ * {@link pv.Scale.OrdinalScale#domain}. The following colors are used:
+ *
+ * <div style="background:#9c9ede;">#9c9ede</div>
+ * <div style="background:#7375b5;">#7375b5</div>
+ * <div style="background:#4a5584;">#4a5584</div>
+ * <div style="background:#cedb9c;">#cedb9c</div>
+ * <div style="background:#b5cf6b;">#b5cf6b</div>
+ * <div style="background:#8ca252;">#8ca252</div>
+ * <div style="background:#637939;">#637939</div>
+ * <div style="background:#e7cb94;">#e7cb94</div>
+ * <div style="background:#e7ba52;">#e7ba52</div>
+ * <div style="background:#bd9e39;">#bd9e39</div>
+ * <div style="background:#8c6d31;">#8c6d31</div>
+ * <div style="background:#e7969c;">#e7969c</div>
+ * <div style="background:#d6616b;">#d6616b</div>
+ * <div style="background:#ad494a;">#ad494a</div>
+ * <div style="background:#843c39;">#843c39</div>
+ * <div style="background:#de9ed6;">#de9ed6</div>
+ * <div style="background:#ce6dbd;">#ce6dbd</div>
+ * <div style="background:#a55194;">#a55194</div>
+ * <div style="background:#7b4173;">#7b4173</div>
+ *
+ * @param {number...} domain... domain values.
+ * @returns {pv.Scale.ordinal} a new ordinal color scale.
+ * @see pv.color
+ */
+pv.Colors.category19 = function() {
+  var scale = pv.colors(
+      "#9c9ede", "#7375b5", "#4a5584", "#cedb9c", "#b5cf6b",
+      "#8ca252", "#637939", "#e7cb94", "#e7ba52", "#bd9e39",
+      "#8c6d31", "#e7969c", "#d6616b", "#ad494a", "#843c39",
+      "#de9ed6", "#ce6dbd", "#a55194", "#7b4173");
+  scale.domain.apply(scale, arguments);
+  return scale;
+};
diff --git a/vendor/protovis/src/color/Ramp.js b/vendor/protovis/src/color/Ramp.js
new file mode 100644
index 0000000..5a6c7e3
--- /dev/null
+++ b/vendor/protovis/src/color/Ramp.js
@@ -0,0 +1,17 @@
+/**
+ * Returns a linear color ramp from the specified <tt>start</tt> color to the
+ * specified <tt>end</tt> color. The color arguments may be specified either as
+ * <tt>string</tt>s or as {@link pv.Color}s. This is equivalent to:
+ *
+ * <pre>    pv.Scale.linear().domain(0, 1).range(...)</pre>
+ *
+ * @param {string} start the start color; may be a <tt>pv.Color</tt>.
+ * @param {string} end the end color; may be a <tt>pv.Color</tt>.
+ * @returns {Function} a color ramp from <tt>start</tt> to <tt>end</tt>.
+ * @see pv.Scale.linear
+ */
+pv.ramp = function(start, end) {
+  var scale = pv.Scale.linear();
+  scale.range.apply(scale, arguments);
+  return scale;
+};
diff --git a/vendor/protovis/src/data/Arrays.js b/vendor/protovis/src/data/Arrays.js
new file mode 100644
index 0000000..90b832c
--- /dev/null
+++ b/vendor/protovis/src/data/Arrays.js
@@ -0,0 +1,277 @@
+/**
+ * @private A private variant of Array.prototype.map that supports the index
+ * property.
+ */
+pv.map = function(array, f) {
+  var o = {};
+  return f
+      ? array.map(function(d, i) { o.index = i; return f.call(o, d); })
+      : array.slice();
+};
+
+/**
+ * Concatenates the specified array with itself <i>n</i> times. For example,
+ * <tt>pv.repeat([1, 2])</tt> returns [1, 2, 1, 2].
+ *
+ * @param {array} a an array.
+ * @param {number} [n] the number of times to repeat; defaults to two.
+ * @returns {array} an array that repeats the specified array.
+ */
+pv.repeat = function(array, n) {
+  if (arguments.length == 1) n = 2;
+  return pv.blend(pv.range(n).map(function() { return array; }));
+};
+
+/**
+ * Given two arrays <tt>a</tt> and <tt>b</tt>, <style
+ * type="text/css">sub{line-height:0}</style> returns an array of all possible
+ * pairs of elements [a<sub>i</sub>, b<sub>j</sub>]. The outer loop is on array
+ * <i>a</i>, while the inner loop is on <i>b</i>, such that the order of
+ * returned elements is [a<sub>0</sub>, b<sub>0</sub>], [a<sub>0</sub>,
+ * b<sub>1</sub>], ... [a<sub>0</sub>, b<sub>m</sub>], [a<sub>1</sub>,
+ * b<sub>0</sub>], [a<sub>1</sub>, b<sub>1</sub>], ... [a<sub>1</sub>,
+ * b<sub>m</sub>], ... [a<sub>n</sub>, b<sub>m</sub>]. If either array is empty,
+ * an empty array is returned.
+ *
+ * @param {array} a an array.
+ * @param {array} b an array.
+ * @returns {array} an array of pairs of elements in <tt>a</tt> and <tt>b</tt>.
+ */
+pv.cross = function(a, b) {
+  var array = [];
+  for (var i = 0, n = a.length, m = b.length; i < n; i++) {
+    for (var j = 0, x = a[i]; j < m; j++) {
+      array.push([x, b[j]]);
+    }
+  }
+  return array;
+};
+
+/**
+ * Given the specified array of arrays, concatenates the arrays into a single
+ * array. If the individual arrays are explicitly known, an alternative to blend
+ * is to use JavaScript's <tt>concat</tt> method directly. These two equivalent
+ * expressions:<ul>
+ *
+ * <li><tt>pv.blend([[1, 2, 3], ["a", "b", "c"]])</tt>
+ * <li><tt>[1, 2, 3].concat(["a", "b", "c"])</tt>
+ *
+ * </ul>return [1, 2, 3, "a", "b", "c"].
+ *
+ * @param {array[]} arrays an array of arrays.
+ * @returns {array} an array containing all the elements of each array in
+ * <tt>arrays</tt>.
+ */
+pv.blend = function(arrays) {
+  return Array.prototype.concat.apply([], arrays);
+};
+
+/**
+ * Given the specified array of arrays, <style
+ * type="text/css">sub{line-height:0}</style> transposes each element
+ * array<sub>ij</sub> with array<sub>ji</sub>. If the array has dimensions
+ * <i>n</i>×<i>m</i>, it will have dimensions <i>m</i>×<i>n</i>
+ * after this method returns. This method transposes the elements of the array
+ * in place, mutating the array, and returning a reference to the array.
+ *
+ * @param {array[]} arrays an array of arrays.
+ * @returns {array[]} the passed-in array, after transposing the elements.
+ */
+pv.transpose = function(arrays) {
+  var n = arrays.length, m = pv.max(arrays, function(d) { return d.length; });
+
+  if (m > n) {
+    arrays.length = m;
+    for (var i = n; i < m; i++) {
+      arrays[i] = new Array(n);
+    }
+    for (var i = 0; i < n; i++) {
+      for (var j = i + 1; j < m; j++) {
+        var t = arrays[i][j];
+        arrays[i][j] = arrays[j][i];
+        arrays[j][i] = t;
+      }
+    }
+  } else {
+    for (var i = 0; i < m; i++) {
+      arrays[i].length = n;
+    }
+    for (var i = 0; i < n; i++) {
+      for (var j = 0; j < i; j++) {
+        var t = arrays[i][j];
+        arrays[i][j] = arrays[j][i];
+        arrays[j][i] = t;
+      }
+    }
+  }
+
+  arrays.length = m;
+  for (var i = 0; i < m; i++) {
+    arrays[i].length = n;
+  }
+
+  return arrays;
+};
+
+/**
+ * Returns a normalized copy of the specified array, such that the sum of the
+ * returned elements sum to one. If the specified array is not an array of
+ * numbers, an optional accessor function <tt>f</tt> can be specified to map the
+ * elements to numbers. For example, if <tt>array</tt> is an array of objects,
+ * and each object has a numeric property "foo", the expression
+ *
+ * <pre>pv.normalize(array, function(d) d.foo)</pre>
+ *
+ * returns a normalized array on the "foo" property. If an accessor function is
+ * not specified, the identity function is used. Accessor functions can refer to
+ * <tt>this.index</tt>.
+ *
+ * @param {array} array an array of objects, or numbers.
+ * @param {function} [f] an optional accessor function.
+ * @returns {number[]} an array of numbers that sums to one.
+ */
+pv.normalize = function(array, f) {
+  var norm = pv.map(array, f), sum = pv.sum(norm);
+  for (var i = 0; i < norm.length; i++) norm[i] /= sum;
+  return norm;
+};
+
+/**
+ * Returns a permutation of the specified array, using the specified array of
+ * indexes. The returned array contains the corresponding element in
+ * <tt>array</tt> for each index in <tt>indexes</tt>, in order. For example,
+ *
+ * <pre>pv.permute(["a", "b", "c"], [1, 2, 0])</pre>
+ *
+ * returns <tt>["b", "c", "a"]</tt>. It is acceptable for the array of indexes
+ * to be a different length from the array of elements, and for indexes to be
+ * duplicated or omitted. The optional accessor function <tt>f</tt> can be used
+ * to perform a simultaneous mapping of the array elements. Accessor functions
+ * can refer to <tt>this.index</tt>.
+ *
+ * @param {array} array an array.
+ * @param {number[]} indexes an array of indexes into <tt>array</tt>.
+ * @param {function} [f] an optional accessor function.
+ * @returns {array} an array of elements from <tt>array</tt>; a permutation.
+ */
+pv.permute = function(array, indexes, f) {
+  if (!f) f = pv.identity;
+  var p = new Array(indexes.length), o = {};
+  indexes.forEach(function(j, i) { o.index = j; p[i] = f.call(o, array[j]); });
+  return p;
+};
+
+/**
+ * Returns a map from key to index for the specified <tt>keys</tt> array. For
+ * example,
+ *
+ * <pre>pv.numerate(["a", "b", "c"])</pre>
+ *
+ * returns <tt>{a: 0, b: 1, c: 2}</tt>. Note that since JavaScript maps only
+ * support string keys, <tt>keys</tt> must contain strings, or other values that
+ * naturally map to distinct string values. Alternatively, an optional accessor
+ * function <tt>f</tt> can be specified to compute the string key for the given
+ * element. Accessor functions can refer to <tt>this.index</tt>.
+ *
+ * @param {array} keys an array, usually of string keys.
+ * @param {function} [f] an optional key function.
+ * @returns a map from key to index.
+ */
+pv.numerate = function(keys, f) {
+  if (!f) f = pv.identity;
+  var map = {}, o = {};
+  keys.forEach(function(x, i) { o.index = i; map[f.call(o, x)] = i; });
+  return map;
+};
+
+/**
+ * Returns the unique elements in the specified array, in the order they appear.
+ * Note that since JavaScript maps only support string keys, <tt>array</tt> must
+ * contain strings, or other values that naturally map to distinct string
+ * values. Alternatively, an optional accessor function <tt>f</tt> can be
+ * specified to compute the string key for the given element. Accessor functions
+ * can refer to <tt>this.index</tt>.
+ *
+ * @param {array} array an array, usually of string keys.
+ * @param {function} [f] an optional key function.
+ * @returns {array} the unique values.
+ */
+pv.uniq = function(array, f) {
+  if (!f) f = pv.identity;
+  var map = {}, keys = [], o = {}, y;
+  array.forEach(function(x, i) {
+    o.index = i;
+    y = f.call(o, x);
+    if (!(y in map)) map[y] = keys.push(y);
+  });
+  return keys;
+};
+
+/**
+ * The comparator function for natural order. This can be used in conjunction with
+ * the built-in array <tt>sort</tt> method to sort elements by their natural
+ * order, ascending. Note that if no comparator function is specified to the
+ * built-in <tt>sort</tt> method, the default order is lexicographic, <i>not</i>
+ * natural!
+ *
+ * @see <a
+ * href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/sort">Array.sort</a>.
+ * @param a an element to compare.
+ * @param b an element to compare.
+ * @returns {number} negative if a < b; positive if a > b; otherwise 0.
+ */
+pv.naturalOrder = function(a, b) {
+  return (a < b) ? -1 : ((a > b) ? 1 : 0);
+};
+
+/**
+ * The comparator function for reverse natural order. This can be used in
+ * conjunction with the built-in array <tt>sort</tt> method to sort elements by
+ * their natural order, descending. Note that if no comparator function is
+ * specified to the built-in <tt>sort</tt> method, the default order is
+ * lexicographic, <i>not</i> natural!
+ *
+ * @see #naturalOrder
+ * @param a an element to compare.
+ * @param b an element to compare.
+ * @returns {number} negative if a < b; positive if a > b; otherwise 0.
+ */
+pv.reverseOrder = function(b, a) {
+  return (a < b) ? -1 : ((a > b) ? 1 : 0);
+};
+
+/**
+ * Searches the specified array of numbers for the specified value using the
+ * binary search algorithm. The array must be sorted (as by the <tt>sort</tt>
+ * method) prior to making this call. If it is not sorted, the results are
+ * undefined. If the array contains multiple elements with the specified value,
+ * there is no guarantee which one will be found.
+ *
+ * <p>The <i>insertion point</i> is defined as the point at which the value
+ * would be inserted into the array: the index of the first element greater than
+ * the value, or <tt>array.length</tt>, if all elements in the array are less
+ * than the specified value. Note that this guarantees that the return value
+ * will be nonnegative if and only if the value is found.
+ *
+ * @param {number[]} array the array to be searched.
+ * @param {number} value the value to be searched for.
+ * @returns the index of the search value, if it is contained in the array;
+ * otherwise, (-(<i>insertion point</i>) - 1).
+ * @param {function} [f] an optional key function.
+ */
+pv.search = function(array, value, f) {
+  if (!f) f = pv.identity;
+  var low = 0, high = array.length - 1;
+  while (low <= high) {
+    var mid = (low + high) >> 1, midValue = f(array[mid]);
+    if (midValue < value) low = mid + 1;
+    else if (midValue > value) high = mid - 1;
+    else return mid;
+  }
+  return -low - 1;
+};
+
+pv.search.index = function(array, value, f) {
+  var i = pv.search(array, value, f);
+  return (i < 0) ? (-i - 1) : i;
+};
diff --git a/vendor/protovis/src/data/Dom.js b/vendor/protovis/src/data/Dom.js
new file mode 100644
index 0000000..b7e354d
--- /dev/null
+++ b/vendor/protovis/src/data/Dom.js
@@ -0,0 +1,380 @@
+/**
+ * Returns a {@link pv.Dom} operator for the given map. This is a convenience
+ * factory method, equivalent to <tt>new pv.Dom(map)</tt>. To apply the operator
+ * and retrieve the root node, call {@link pv.Dom#root}; to retrieve all nodes
+ * flattened, use {@link pv.Dom#nodes}.
+ *
+ * @see pv.Dom
+ * @param map a map from which to construct a DOM.
+ * @returns {pv.Dom} a DOM operator for the specified map.
+ */
+pv.dom = function(map) {
+  return new pv.Dom(map);
+};
+
+/**
+ * Constructs a DOM operator for the specified map. This constructor should not
+ * be invoked directly; use {@link pv.dom} instead.
+ *
+ * @class Represets a DOM operator for the specified map. This allows easy
+ * transformation of a hierarchical JavaScript object (such as a JSON map) to a
+ * W3C Document Object Model hierarchy. For more information on which attributes
+ * and methods from the specification are supported, see {@link pv.Dom.Node}.
+ *
+ * <p>Leaves in the map are determined using an associated <i>leaf</i> function;
+ * see {@link #leaf}. By default, leaves are any value whose type is not
+ * "object", such as numbers or strings.
+ *
+ * @param map a map from which to construct a DOM.
+ */
+pv.Dom = function(map) {
+  this.$map = map;
+};
+
+/** @private The default leaf function. */
+pv.Dom.prototype.$leaf = function(n) {
+  return typeof n != "object";
+};
+
+/**
+ * Sets or gets the leaf function for this DOM operator. The leaf function
+ * identifies which values in the map are leaves, and which are internal nodes.
+ * By default, objects are considered internal nodes, and primitives (such as
+ * numbers and strings) are considered leaves.
+ *
+ * @param {function} f the new leaf function.
+ * @returns the current leaf function, or <tt>this</tt>.
+ */
+pv.Dom.prototype.leaf = function(f) {
+  if (arguments.length) {
+    this.$leaf = f;
+    return this;
+  }
+  return this.$leaf;
+};
+
+/**
+ * Applies the DOM operator, returning the root node.
+ *
+ * @returns {pv.Dom.Node} the root node.
+ * @param {string} [nodeName] optional node name for the root.
+ */
+pv.Dom.prototype.root = function(nodeName) {
+  var leaf = this.$leaf, root = recurse(this.$map);
+
+  /** @private */
+  function recurse(map) {
+    var n = new pv.Dom.Node();
+    for (var k in map) {
+      var v = map[k];
+      n.appendChild(leaf(v) ? new pv.Dom.Node(v) : recurse(v)).nodeName = k;
+    }
+    return n;
+  }
+
+  root.nodeName = nodeName;
+  return root;
+};
+
+/**
+ * Applies the DOM operator, returning the array of all nodes in preorder
+ * traversal.
+ *
+ * @returns {array} the array of nodes in preorder traversal.
+ */
+pv.Dom.prototype.nodes = function() {
+  return this.root().nodes();
+};
+
+/**
+ * Constructs a DOM node for the specified value. Instances of this class are
+ * not typically created directly; instead they are generated from a JavaScript
+ * map using the {@link pv.Dom} operator.
+ *
+ * @class Represents a <tt>Node</tt> in the W3C Document Object Model.
+ */
+pv.Dom.Node = function(value) {
+  this.nodeValue = value;
+  this.childNodes = [];
+};
+
+/**
+ * The node name. When generated from a map, the node name corresponds to the
+ * key at the given level in the map. Note that the root node has no associated
+ * key, and thus has an undefined node name (and no <tt>parentNode</tt>).
+ *
+ * @type string
+ * @field pv.Dom.Node.prototype.nodeName
+ */
+
+/**
+ * The node value. When generated from a map, node value corresponds to the leaf
+ * value for leaf nodes, and is undefined for internal nodes.
+ *
+ * @field pv.Dom.Node.prototype.nodeValue
+ */
+
+/**
+ * The array of child nodes. This array is empty for leaf nodes. An easy way to
+ * check if child nodes exist is to query <tt>firstChild</tt>.
+ *
+ * @type array
+ * @field pv.Dom.Node.prototype.childNodes
+ */
+
+/**
+ * The parent node, which is null for root nodes.
+ *
+ * @type pv.Dom.Node
+ */
+pv.Dom.Node.prototype.parentNode = null;
+
+/**
+ * The first child, which is null for leaf nodes.
+ *
+ * @type pv.Dom.Node
+ */
+pv.Dom.Node.prototype.firstChild = null;
+
+/**
+ * The last child, which is null for leaf nodes.
+ *
+ * @type pv.Dom.Node
+ */
+pv.Dom.Node.prototype.lastChild = null;
+
+/**
+ * The previous sibling node, which is null for the first child.
+ *
+ * @type pv.Dom.Node
+ */
+pv.Dom.Node.prototype.previousSibling = null;
+
+/**
+ * The next sibling node, which is null for the last child.
+ *
+ * @type pv.Dom.Node
+ */
+pv.Dom.Node.prototype.nextSibling = null;
+
+/**
+ * Removes the specified child node from this node.
+ *
+ * @throws Error if the specified child is not a child of this node.
+ * @returns {pv.Dom.Node} the removed child.
+ */
+pv.Dom.Node.prototype.removeChild = function(n) {
+  var i = this.childNodes.indexOf(n);
+  if (i == -1) throw new Error("child not found");
+  this.childNodes.splice(i, 1);
+  if (n.previousSibling) n.previousSibling.nextSibling = n.nextSibling;
+  else this.firstChild = n.nextSibling;
+  if (n.nextSibling) n.nextSibling.previousSibling = n.previousSibling;
+  else this.lastChild = n.previousSibling;
+  delete n.nextSibling;
+  delete n.previousSibling;
+  delete n.parentNode;
+  return n;
+};
+
+/**
+ * Appends the specified child node to this node. If the specified child is
+ * already part of the DOM, the child is first removed before being added to
+ * this node.
+ *
+ * @returns {pv.Dom.Node} the appended child.
+ */
+pv.Dom.Node.prototype.appendChild = function(n) {
+  if (n.parentNode) n.parentNode.removeChild(n);
+  n.parentNode = this;
+  n.previousSibling = this.lastChild;
+  if (this.lastChild) this.lastChild.nextSibling = n;
+  else this.firstChild = n;
+  this.lastChild = n;
+  this.childNodes.push(n);
+  return n;
+};
+
+/**
+ * Inserts the specified child <i>n</i> before the given reference child
+ * <i>r</i> of this node. If <i>r</i> is null, this method is equivalent to
+ * {@link #appendChild}. If <i>n</i> is already part of the DOM, it is first
+ * removed before being inserted.
+ *
+ * @throws Error if <i>r</i> is non-null and not a child of this node.
+ * @returns {pv.Dom.Node} the inserted child.
+ */
+pv.Dom.Node.prototype.insertBefore = function(n, r) {
+  if (!r) return this.appendChild(n);
+  var i = this.childNodes.indexOf(r);
+  if (i == -1) throw new Error("child not found");
+  if (n.parentNode) n.parentNode.removeChild(n);
+  n.parentNode = this;
+  n.nextSibling = r;
+  n.previousSibling = r.previousSibling;
+  if (r.previousSibling) {
+    r.previousSibling.nextSibling = n;
+  } else {
+    if (r == this.lastChild) this.lastChild = n;
+    this.firstChild = n;
+  }
+  this.childNodes.splice(i, 0, n);
+  return n;
+};
+
+/**
+ * Replaces the specified child <i>r</i> of this node with the node <i>n</i>. If
+ * <i>n</i> is already part of the DOM, it is first removed before being added.
+ *
+ * @throws Error if <i>r</i> is not a child of this node.
+ */
+pv.Dom.Node.prototype.replaceChild = function(n, r) {
+  var i = this.childNodes.indexOf(r);
+  if (i == -1) throw new Error("child not found");
+  if (n.parentNode) n.parentNode.removeChild(n);
+  n.parentNode = this;
+  n.nextSibling = r.nextSibling;
+  n.previousSibling = r.previousSibling;
+  if (r.previousSibling) r.previousSibling.nextSibling = n;
+  else this.firstChild = n;
+  if (r.nextSibling) r.nextSibling.previousSibling = n;
+  else this.lastChild = n;
+  this.childNodes[i] = n;
+  return r;
+};
+
+/**
+ * Visits each node in the tree in preorder traversal, applying the specified
+ * function <i>f</i>. The arguments to the function are:<ol>
+ *
+ * <li>The current node.
+ * <li>The current depth, starting at 0 for the root node.</ol>
+ *
+ * @param {function} f a function to apply to each node.
+ */
+pv.Dom.Node.prototype.visitBefore = function(f) {
+  function visit(n, i) {
+    f(n, i);
+    for (var c = n.firstChild; c; c = c.nextSibling) {
+      visit(c, i + 1);
+    }
+  }
+  visit(this, 0);
+};
+
+/**
+ * Visits each node in the tree in postorder traversal, applying the specified
+ * function <i>f</i>. The arguments to the function are:<ol>
+ *
+ * <li>The current node.
+ * <li>The current depth, starting at 0 for the root node.</ol>
+ *
+ * @param {function} f a function to apply to each node.
+ */
+pv.Dom.Node.prototype.visitAfter = function(f) {
+  function visit(n, i) {
+    for (var c = n.firstChild; c; c = c.nextSibling) {
+      visit(c, i + 1);
+    }
+    f(n, i);
+  }
+  visit(this, 0);
+};
+
+/**
+ * Sorts child nodes of this node, and all descendent nodes recursively, using
+ * the specified comparator function <tt>f</tt>. The comparator function is
+ * passed two nodes to compare.
+ *
+ * <p>Note: during the sort operation, the comparator function should not rely
+ * on the tree being well-formed; the values of <tt>previousSibling</tt> and
+ * <tt>nextSibling</tt> for the nodes being compared are not defined during the
+ * sort operation.
+ *
+ * @param {function} f a comparator function.
+ * @returns this.
+ */
+pv.Dom.Node.prototype.sort = function(f) {
+  if (this.firstChild) {
+    this.childNodes.sort(f);
+    var p = this.firstChild = this.childNodes[0], c;
+    delete p.previousSibling;
+    for (var i = 1; i < this.childNodes.length; i++) {
+      p.sort(f);
+      c = this.childNodes[i];
+      c.previousSibling = p;
+      p = p.nextSibling = c;
+    }
+    this.lastChild = p;
+    delete p.nextSibling;
+    p.sort(f);
+  }
+  return this;
+};
+
+/**
+ * Reverses all sibling nodes.
+ *
+ * @returns this.
+ */
+pv.Dom.Node.prototype.reverse = function() {
+  var childNodes = [];
+  this.visitAfter(function(n) {
+      while (n.lastChild) childNodes.push(n.removeChild(n.lastChild));
+      for (var c; c = childNodes.pop();) n.insertBefore(c, n.firstChild);
+    });
+  return this;
+};
+
+/** Returns all descendants of this node in preorder traversal. */
+pv.Dom.Node.prototype.nodes = function() {
+  var array = [];
+
+  /** @private */
+  function flatten(node) {
+    array.push(node);
+    node.childNodes.forEach(flatten);
+  }
+
+  flatten(this, array);
+  return array;
+};
+
+/**
+ * Toggles the child nodes of this node. If this node is not yet toggled, this
+ * method removes all child nodes and appends them to a new <tt>toggled</tt>
+ * array attribute on this node. Otherwise, if this node is toggled, this method
+ * re-adds all toggled child nodes and deletes the <tt>toggled</tt> attribute.
+ *
+ * <p>This method has no effect if the node has no child nodes.
+ *
+ * @param {boolean} [recursive] whether the toggle should apply to descendants.
+ */
+pv.Dom.Node.prototype.toggle = function(recursive) {
+  if (recursive) return this.toggled
+      ? this.visitBefore(function(n) { if (n.toggled) n.toggle(); })
+      : this.visitAfter(function(n) { if (!n.toggled) n.toggle(); });
+  var n = this;
+  if (n.toggled) {
+    for (var c; c = n.toggled.pop();) n.appendChild(c);
+    delete n.toggled;
+  } else if (n.lastChild) {
+    n.toggled = [];
+    while (n.lastChild) n.toggled.push(n.removeChild(n.lastChild));
+  }
+};
+
+/**
+ * Given a flat array of values, returns a simple DOM with each value wrapped by
+ * a node that is a child of the root node.
+ *
+ * @param {array} values.
+ * @returns {array} nodes.
+ */
+pv.nodes = function(values) {
+  var root = new pv.Dom.Node();
+  for (var i = 0; i < values.length; i++) {
+    root.appendChild(new pv.Dom.Node(values[i]));
+  }
+  return root.nodes();
+};
diff --git a/vendor/protovis/src/data/Flatten.js b/vendor/protovis/src/data/Flatten.js
new file mode 100644
index 0000000..117f6f1
--- /dev/null
+++ b/vendor/protovis/src/data/Flatten.js
@@ -0,0 +1,146 @@
+/**
+ * Returns a {@link pv.Flatten} operator for the specified map. This is a
+ * convenience factory method, equivalent to <tt>new pv.Flatten(map)</tt>.
+ *
+ * @see pv.Flatten
+ * @param map a map to flatten.
+ * @returns {pv.Flatten} a flatten operator for the specified map.
+ */
+pv.flatten = function(map) {
+  return new pv.Flatten(map);
+};
+
+/**
+ * Constructs a flatten operator for the specified map. This constructor should
+ * not be invoked directly; use {@link pv.flatten} instead.
+ *
+ * @class Represents a flatten operator for the specified array. Flattening
+ * allows hierarchical maps to be flattened into an array. The levels in the
+ * input tree are specified by <i>key</i> functions.
+ *
+ * <p>For example, consider the following hierarchical data structure of Barley
+ * yields, from various sites in Minnesota during 1931-2:
+ *
+ * <pre>{ 1931: {
+ *     Manchuria: {
+ *       "University Farm": 27.00,
+ *       "Waseca": 48.87,
+ *       "Morris": 27.43,
+ *       ... },
+ *     Glabron: {
+ *       "University Farm": 43.07,
+ *       "Waseca": 55.20,
+ *       ... } },
+ *   1932: {
+ *     ... } }</pre>
+ *
+ * To facilitate visualization, it may be useful to flatten the tree into a
+ * tabular array:
+ *
+ * <pre>var array = pv.flatten(yields)
+ *     .key("year")
+ *     .key("variety")
+ *     .key("site")
+ *     .key("yield")
+ *     .array();</pre>
+ *
+ * This returns an array of object elements. Each element in the array has
+ * attributes corresponding to this flatten operator's keys:
+ *
+ * <pre>{ site: "University Farm", variety: "Manchuria", year: 1931, yield: 27 },
+ * { site: "Waseca", variety: "Manchuria", year: 1931, yield: 48.87 },
+ * { site: "Morris", variety: "Manchuria", year: 1931, yield: 27.43 },
+ * { site: "University Farm", variety: "Glabron", year: 1931, yield: 43.07 },
+ * { site: "Waseca", variety: "Glabron", year: 1931, yield: 55.2 }, ...</pre>
+ *
+ * <p>The flatten operator is roughly the inverse of the {@link pv.Nest} and
+ * {@link pv.Tree} operators.
+ *
+ * @param map a map to flatten.
+ */
+pv.Flatten = function(map) {
+  this.map = map;
+  this.keys = [];
+};
+
+/**
+ * Flattens using the specified key function. Multiple keys may be added to the
+ * flatten; the tiers of the underlying tree must correspond to the specified
+ * keys, in order. The order of the returned array is undefined; however, you
+ * can easily sort it.
+ *
+ * @param {string} key the key name.
+ * @param {function} [f] an optional value map function.
+ * @returns {pv.Nest} this.
+ */
+pv.Flatten.prototype.key = function(key, f) {
+  this.keys.push({name: key, value: f});
+  delete this.$leaf;
+  return this;
+};
+
+/**
+ * Flattens using the specified leaf function. This is an alternative to
+ * specifying an explicit set of keys; the tiers of the underlying tree will be
+ * determined dynamically by recursing on the values, and the resulting keys
+ * will be stored in the entries <tt>keys</tt> attribute. The leaf function must
+ * return true for leaves, and false for internal nodes.
+ *
+ * @param {function} f a leaf function.
+ * @returns {pv.Nest} this.
+ */
+pv.Flatten.prototype.leaf = function(f) {
+  this.keys.length = 0;
+  this.$leaf = f;
+  return this;
+};
+
+/**
+ * Returns the flattened array. Each entry in the array is an object; each
+ * object has attributes corresponding to this flatten operator's keys.
+ *
+ * @returns an array of elements from the flattened map.
+ */
+pv.Flatten.prototype.array = function() {
+  var entries = [], stack = [], keys = this.keys, leaf = this.$leaf;
+
+  /* Recursively visit using the leaf function. */
+  if (leaf) {
+    function recurse(value, i) {
+      if (leaf(value)) {
+        entries.push({keys: stack.slice(), value: value});
+      } else {
+        for (var key in value) {
+          stack.push(key);
+          recurse(value[key], i + 1);
+          stack.pop();
+        }
+      }
+    }
+    recurse(this.map, 0);
+    return entries;
+  }
+
+  /* Recursively visits the specified value. */
+  function visit(value, i) {
+    if (i < keys.length - 1) {
+      for (var key in value) {
+        stack.push(key);
+        visit(value[key], i + 1);
+        stack.pop();
+      }
+    } else {
+      entries.push(stack.concat(value));
+    }
+  }
+
+  visit(this.map, 0);
+  return entries.map(function(stack) {
+      var m = {};
+      for (var i = 0; i < keys.length; i++) {
+        var k = keys[i], v = stack[i];
+        m[k.name] = k.value ? k.value.call(null, v) : v;
+      }
+      return m;
+    });
+};
diff --git a/vendor/protovis/src/data/Histogram.js b/vendor/protovis/src/data/Histogram.js
new file mode 100644
index 0000000..485caae
--- /dev/null
+++ b/vendor/protovis/src/data/Histogram.js
@@ -0,0 +1,120 @@
+/**
+ * Returns a histogram operator for the specified data, with an optional
+ * accessor function. If the data specified is not an array of numbers, an
+ * accessor function must be specified to map the data to numeric values.
+ *
+ * @class Represents a histogram operator.
+ *
+ * @param {array} data an array of numbers or objects.
+ * @param {function} [f] an optional accessor function.
+ */
+pv.histogram = function(data, f) {
+  var frequency = true;
+  return {
+
+    /**
+     * Returns the computed histogram bins. An optional array of numbers,
+     * <tt>ticks</tt>, may be specified as the break points. If the ticks are
+     * not specified, default ticks will be computed using a linear scale on the
+     * data domain.
+     *
+     * <p>The returned array contains {@link pv.histogram.Bin}s. The <tt>x</tt>
+     * attribute corresponds to the bin's start value (inclusive), while the
+     * <tt>dx</tt> attribute stores the bin size (end - start). The <tt>y</tt>
+     * attribute stores either the frequency count or probability, depending on
+     * how the histogram operator has been configured.
+     *
+     * <p>The {@link pv.histogram.Bin} objects are themselves arrays, containing
+     * the data elements present in each bin, i.e., the elements in the
+     * <tt>data</tt> array (prior to invoking the accessor function, if any).
+     * For example, if the data represented countries, and the accessor function
+     * returned the GDP of each country, the returned bins would be arrays of
+     * countries (not GDPs).
+     *
+     * @function
+     * @name pv.histogram.prototype.bins
+     * @param {array} [ticks]
+     * @returns {array}
+     */ /** @private */
+    bins: function(ticks) {
+      var x = pv.map(data, f), bins = [];
+
+      /* Initialize default ticks. */
+      if (!arguments.length) ticks = pv.Scale.linear(x).ticks();
+
+      /* Initialize the bins. */
+      for (var i = 0; i < ticks.length - 1; i++) {
+        var bin = bins[i] = [];
+        bin.x = ticks[i];
+        bin.dx = ticks[i + 1] - ticks[i];
+        bin.y = 0;
+      }
+
+      /* Count the number of samples per bin. */
+      for (var i = 0; i < x.length; i++) {
+        var j = pv.search.index(ticks, x[i]) - 1,
+            bin = bins[Math.max(0, Math.min(bins.length - 1, j))];
+        bin.y++;
+        bin.push(data[i]);
+      }
+
+      /* Convert frequencies to probabilities. */
+      if (!frequency) for (var i = 0; i < bins.length; i++) {
+        bins[i].y /= x.length;
+      }
+
+      return bins;
+    },
+
+    /**
+     * Sets or gets whether this histogram operator returns frequencies or
+     * probabilities.
+     *
+     * @function
+     * @name pv.histogram.prototype.frequency
+     * @param {boolean} [x]
+     * @returns {pv.histogram} this.
+     */ /** @private */
+    frequency: function(x) {
+      if (arguments.length) {
+        frequency = Boolean(x);
+        return this;
+      }
+      return frequency;
+    }
+  };
+};
+
+/**
+ * @class Represents a bin returned by the {@link pv.histogram} operator. Bins
+ * are themselves arrays containing the data elements present in the given bin
+ * (prior to the accessor function being invoked to convert the data object to a
+ * numeric value). These bin arrays have additional attributes with meta
+ * information about the bin.
+ *
+ * @name pv.histogram.Bin
+ * @extends array
+ * @see pv.histogram
+ */
+
+/**
+ * The start value of the bin's range.
+ *
+ * @type number
+ * @name pv.histogram.Bin.prototype.x
+ */
+
+/**
+ * The magnitude value of the bin's range; end - start.
+ *
+ * @type number
+ * @name pv.histogram.Bin.prototype.dx
+ */
+
+/**
+ * The frequency or probability of the bin, depending on how the histogram
+ * operator was configured.
+ *
+ * @type number
+ * @name pv.histogram.Bin.prototype.y
+ */
diff --git a/vendor/protovis/src/data/LinearScale.js b/vendor/protovis/src/data/LinearScale.js
new file mode 100644
index 0000000..40d3a0c
--- /dev/null
+++ b/vendor/protovis/src/data/LinearScale.js
@@ -0,0 +1,54 @@
+/**
+ * Returns a linear scale for the specified domain. The arguments to this
+ * constructor are optional, and equivalent to calling {@link #domain}.
+ * The default domain and range are [0,1].
+ *
+ * @class Represents a linear scale; a function that performs a linear
+ * transformation. <style type="text/css">sub{line-height:0}</style> Most
+ * commonly, a linear scale represents a 1-dimensional linear transformation
+ * from a numeric domain of input data [<i>d<sub>0</sub></i>,
+ * <i>d<sub>1</sub></i>] to a numeric range of pixels [<i>r<sub>0</sub></i>,
+ * <i>r<sub>1</sub></i>]. The equation for such a scale is:
+ *
+ * <blockquote><i>f(x) = (x - d<sub>0</sub>) / (d<sub>1</sub> - d<sub>0</sub>) *
+ * (r<sub>1</sub> - r<sub>0</sub>) + r<sub>0</sub></i></blockquote>
+ *
+ * For example, a linear scale from the domain [0, 100] to range [0, 640]:
+ *
+ * <blockquote><i>f(x) = (x - 0) / (100 - 0) * (640 - 0) + 0</i><br>
+ * <i>f(x) = x / 100 * 640</i><br>
+ * <i>f(x) = x * 6.4</i><br>
+ * </blockquote>
+ *
+ * Thus, saying
+ *
+ * <pre>    .height(function(d) d * 6.4)</pre>
+ *
+ * is identical to
+ *
+ * <pre>    .height(pv.Scale.linear(0, 100).range(0, 640))</pre>
+ *
+ * Note that the scale is itself a function, and thus can be used as a property
+ * directly, assuming that the data associated with a mark is a number. While
+ * this is convenient for single-use scales, frequently it is desirable to
+ * define scales globally:
+ *
+ * <pre>var y = pv.Scale.linear(0, 100).range(0, 640);</pre>
+ *
+ * The <tt>y</tt> scale can now be equivalently referenced within a property:
+ *
+ * <pre>    .height(function(d) y(d))</pre>
+ *
+ * Alternatively, if the data are not simple numbers, the appropriate value can
+ * be passed to the <tt>y</tt> scale (e.g., <tt>d.foo</tt>). The {@link #by}
+ * method similarly allows the data to be mapped to a numeric value before
+ * performing the linear transformation.
+ *
+ * @param {number...} domain... optional domain values.
+ * @extends pv.Scale.quantitative
+ */
+pv.Scale.linear = function() {
+  var scale = pv.Scale.quantitative();
+  scale.domain.apply(scale, arguments);
+  return scale;
+};
diff --git a/vendor/protovis/src/data/LogScale.js b/vendor/protovis/src/data/LogScale.js
new file mode 100644
index 0000000..206351f
--- /dev/null
+++ b/vendor/protovis/src/data/LogScale.js
@@ -0,0 +1,142 @@
+/**
+ * Returns a log scale for the specified domain. The arguments to this
+ * constructor are optional, and equivalent to calling {@link #domain}.
+ * The default domain is [1,10] and the default range is [0,1].
+ *
+ * @class Represents a log scale. <style
+ * type="text/css">sub{line-height:0}</style> Most commonly, a log scale
+ * represents a 1-dimensional log transformation from a numeric domain of input
+ * data [<i>d<sub>0</sub></i>, <i>d<sub>1</sub></i>] to a numeric range of
+ * pixels [<i>r<sub>0</sub></i>, <i>r<sub>1</sub></i>]. The equation for such a
+ * scale is:
+ *
+ * <blockquote><i>f(x) = (log(x) - log(d<sub>0</sub>)) / (log(d<sub>1</sub>) -
+ * log(d<sub>0</sub>)) * (r<sub>1</sub> - r<sub>0</sub>) +
+ * r<sub>0</sub></i></blockquote>
+ *
+ * where <i>log(x)</i> represents the zero-symmetric logarthim of <i>x</i> using
+ * the scale's associated base (default: 10, see {@link pv.logSymmetric}). For
+ * example, a log scale from the domain [1, 100] to range [0, 640]:
+ *
+ * <blockquote><i>f(x) = (log(x) - log(1)) / (log(100) - log(1)) * (640 - 0) + 0</i><br>
+ * <i>f(x) = log(x) / 2 * 640</i><br>
+ * <i>f(x) = log(x) * 320</i><br>
+ * </blockquote>
+ *
+ * Thus, saying
+ *
+ * <pre>    .height(function(d) Math.log(d) * 138.974)</pre>
+ *
+ * is equivalent to
+ *
+ * <pre>    .height(pv.Scale.log(1, 100).range(0, 640))</pre>
+ *
+ * Note that the scale is itself a function, and thus can be used as a property
+ * directly, assuming that the data associated with a mark is a number. While
+ * this is convenient for single-use scales, frequently it is desirable to
+ * define scales globally:
+ *
+ * <pre>var y = pv.Scale.log(1, 100).range(0, 640);</pre>
+ *
+ * The <tt>y</tt> scale can now be equivalently referenced within a property:
+ *
+ * <pre>    .height(function(d) y(d))</pre>
+ *
+ * Alternatively, if the data are not simple numbers, the appropriate value can
+ * be passed to the <tt>y</tt> scale (e.g., <tt>d.foo</tt>). The {@link #by}
+ * method similarly allows the data to be mapped to a numeric value before
+ * performing the log transformation.
+ *
+ * @param {number...} domain... optional domain values.
+ * @extends pv.Scale.quantitative
+ */
+pv.Scale.log = function() {
+  var scale = pv.Scale.quantitative(1, 10),
+      b, // logarithm base
+      p, // cached Math.log(b)
+      /** @ignore */ log = function(x) { return Math.log(x) / p; },
+      /** @ignore */ pow = function(y) { return Math.pow(b, y); };
+
+  /**
+   * Returns an array of evenly-spaced, suitably-rounded values in the input
+   * domain. These values are frequently used in conjunction with
+   * {@link pv.Rule} to display tick marks or grid lines.
+   *
+   * @function
+   * @name pv.Scale.log.prototype.ticks
+   * @returns {number[]} an array input domain values to use as ticks.
+   */
+  scale.ticks = function() {
+    // TODO support non-uniform domains
+    var d = scale.domain(),
+        n = d[0] < 0,
+        i = Math.floor(n ? -log(-d[0]) : log(d[0])),
+        j = Math.ceil(n ? -log(-d[1]) : log(d[1])),
+        ticks = [];
+    if (n) {
+      ticks.push(-pow(-i));
+      for (; i++ < j;) for (var k = b - 1; k > 0; k--) ticks.push(-pow(-i) * k);
+    } else {
+      for (; i < j; i++) for (var k = 1; k < b; k++) ticks.push(pow(i) * k);
+      ticks.push(pow(i));
+    }
+    for (i = 0; ticks[i] < d[0]; i++); // strip small values
+    for (j = ticks.length; ticks[j - 1] > d[1]; j--); // strip big values
+    return ticks.slice(i, j);
+  };
+
+  /**
+   * Formats the specified tick value using the appropriate precision, assuming
+   * base 10.
+   *
+   * @function
+   * @name pv.Scale.log.prototype.tickFormat
+   * @param {number} t a tick value.
+   * @returns {string} a formatted tick value.
+   */
+  scale.tickFormat = function(t) {
+    return t.toPrecision(1);
+  };
+
+  /**
+   * "Nices" this scale, extending the bounds of the input domain to
+   * evenly-rounded values. This method uses {@link pv.logFloor} and
+   * {@link pv.logCeil}. Nicing is useful if the domain is computed dynamically
+   * from data, and may be irregular. For example, given a domain of
+   * [0.20147987687960267, 0.996679553296417], a call to <tt>nice()</tt> might
+   * extend the domain to [0.1, 1].
+   *
+   * <p>This method must be invoked each time after setting the domain (and
+   * base).
+   *
+   * @function
+   * @name pv.Scale.log.prototype.nice
+   * @returns {pv.Scale.log} <tt>this</tt>.
+   */
+  scale.nice = function() {
+    // TODO support non-uniform domains
+    var d = scale.domain();
+    return scale.domain(pv.logFloor(d[0], b), pv.logCeil(d[1], b));
+  };
+
+  /**
+   * Sets or gets the logarithm base. Defaults to 10.
+   *
+   * @function
+   * @name pv.Scale.log.prototype.base
+   * @param {number} [v] the new base.
+   * @returns {pv.Scale.log} <tt>this</tt>, or the current base.
+   */
+  scale.base = function(v) {
+    if (arguments.length) {
+      b = Number(v);
+      p = Math.log(b);
+      scale.transform(log, pow); // update transformed domain
+      return this;
+    }
+    return b;
+  };
+
+  scale.domain.apply(scale, arguments);
+  return scale.base(10);
+};
diff --git a/vendor/protovis/src/data/Nest.js b/vendor/protovis/src/data/Nest.js
new file mode 100644
index 0000000..22cd601
--- /dev/null
+++ b/vendor/protovis/src/data/Nest.js
@@ -0,0 +1,257 @@
+/**
+ * Returns a {@link pv.Nest} operator for the specified array. This is a
+ * convenience factory method, equivalent to <tt>new pv.Nest(array)</tt>.
+ *
+ * @see pv.Nest
+ * @param {array} array an array of elements to nest.
+ * @returns {pv.Nest} a nest operator for the specified array.
+ */
+pv.nest = function(array) {
+  return new pv.Nest(array);
+};
+
+/**
+ * Constructs a nest operator for the specified array. This constructor should
+ * not be invoked directly; use {@link pv.nest} instead.
+ *
+ * @class Represents a {@link Nest} operator for the specified array. Nesting
+ * allows elements in an array to be grouped into a hierarchical tree
+ * structure. The levels in the tree are specified by <i>key</i> functions. The
+ * leaf nodes of the tree can be sorted by value, while the internal nodes can
+ * be sorted by key. Finally, the tree can be returned either has a
+ * multidimensional array via {@link #entries}, or as a hierarchical map via
+ * {@link #map}. The {@link #rollup} routine similarly returns a map, collapsing
+ * the elements in each leaf node using a summary function.
+ *
+ * <p>For example, consider the following tabular data structure of Barley
+ * yields, from various sites in Minnesota during 1931-2:
+ *
+ * <pre>{ yield: 27.00, variety: "Manchuria", year: 1931, site: "University Farm" },
+ * { yield: 48.87, variety: "Manchuria", year: 1931, site: "Waseca" },
+ * { yield: 27.43, variety: "Manchuria", year: 1931, site: "Morris" }, ...</pre>
+ *
+ * To facilitate visualization, it may be useful to nest the elements first by
+ * year, and then by variety, as follows:
+ *
+ * <pre>var nest = pv.nest(yields)
+ *     .key(function(d) d.year)
+ *     .key(function(d) d.variety)
+ *     .entries();</pre>
+ *
+ * This returns a nested array. Each element of the outer array is a key-values
+ * pair, listing the values for each distinct key:
+ *
+ * <pre>{ key: 1931, values: [
+ *   { key: "Manchuria", values: [
+ *       { yield: 27.00, variety: "Manchuria", year: 1931, site: "University Farm" },
+ *       { yield: 48.87, variety: "Manchuria", year: 1931, site: "Waseca" },
+ *       { yield: 27.43, variety: "Manchuria", year: 1931, site: "Morris" },
+ *       ...
+ *     ] },
+ *   { key: "Glabron", values: [
+ *       { yield: 43.07, variety: "Glabron", year: 1931, site: "University Farm" },
+ *       { yield: 55.20, variety: "Glabron", year: 1931, site: "Waseca" },
+ *       ...
+ *     ] },
+ *   ] },
+ * { key: 1932, values: ... }</pre>
+ *
+ * Further details, including sorting and rollup, is provided below on the
+ * corresponding methods.
+ *
+ * @param {array} array an array of elements to nest.
+ */
+pv.Nest = function(array) {
+  this.array = array;
+  this.keys = [];
+};
+
+/**
+ * Nests using the specified key function. Multiple keys may be added to the
+ * nest; the array elements will be nested in the order keys are specified.
+ *
+ * @param {function} key a key function; must return a string or suitable map
+ * key.
+ * @returns {pv.Nest} this.
+ */
+pv.Nest.prototype.key = function(key) {
+  this.keys.push(key);
+  return this;
+};
+
+/**
+ * Sorts the previously-added keys. The natural sort order is used by default
+ * (see {@link pv.naturalOrder}); if an alternative order is desired,
+ * <tt>order</tt> should be a comparator function. If this method is not called
+ * (i.e., keys are <i>unsorted</i>), keys will appear in the order they appear
+ * in the underlying elements array. For example,
+ *
+ * <pre>pv.nest(yields)
+ *     .key(function(d) d.year)
+ *     .key(function(d) d.variety)
+ *     .sortKeys()
+ *     .entries()</pre>
+ *
+ * groups yield data by year, then variety, and sorts the variety groups
+ * lexicographically (since the variety attribute is a string).
+ *
+ * <p>Key sort order is only used in conjunction with {@link #entries}, which
+ * returns an array of key-values pairs. If the nest is used to construct a
+ * {@link #map} instead, keys are unsorted.
+ *
+ * @param {function} [order] an optional comparator function.
+ * @returns {pv.Nest} this.
+ */
+pv.Nest.prototype.sortKeys = function(order) {
+  this.keys[this.keys.length - 1].order = order || pv.naturalOrder;
+  return this;
+};
+
+/**
+ * Sorts the leaf values. The natural sort order is used by default (see
+ * {@link pv.naturalOrder}); if an alternative order is desired, <tt>order</tt>
+ * should be a comparator function. If this method is not called (i.e., values
+ * are <i>unsorted</i>), values will appear in the order they appear in the
+ * underlying elements array. For example,
+ *
+ * <pre>pv.nest(yields)
+ *     .key(function(d) d.year)
+ *     .key(function(d) d.variety)
+ *     .sortValues(function(a, b) a.yield - b.yield)
+ *     .entries()</pre>
+ *
+ * groups yield data by year, then variety, and sorts the values for each
+ * variety group by yield.
+ *
+ * <p>Value sort order, unlike keys, applies to both {@link #entries} and
+ * {@link #map}. It has no effect on {@link #rollup}.
+ *
+ * @param {function} [order] an optional comparator function.
+ * @returns {pv.Nest} this.
+ */
+pv.Nest.prototype.sortValues = function(order) {
+  this.order = order || pv.naturalOrder;
+  return this;
+};
+
+/**
+ * Returns a hierarchical map of values. Each key adds one level to the
+ * hierarchy. With only a single key, the returned map will have a key for each
+ * distinct value of the key function; the correspond value with be an array of
+ * elements with that key value. If a second key is added, this will be a nested
+ * map. For example:
+ *
+ * <pre>pv.nest(yields)
+ *     .key(function(d) d.variety)
+ *     .key(function(d) d.site)
+ *     .map()</pre>
+ *
+ * returns a map <tt>m</tt> such that <tt>m[variety][site]</tt> is an array, a subset of
+ * <tt>yields</tt>, with each element having the given variety and site.
+ *
+ * @returns a hierarchical map of values.
+ */
+pv.Nest.prototype.map = function() {
+  var map = {}, values = [];
+
+  /* Build the map. */
+  for (var i, j = 0; j < this.array.length; j++) {
+    var x = this.array[j];
+    var m = map;
+    for (i = 0; i < this.keys.length - 1; i++) {
+      var k = this.keys[i](x);
+      if (!m[k]) m[k] = {};
+      m = m[k];
+    }
+    k = this.keys[i](x);
+    if (!m[k]) {
+      var a = [];
+      values.push(a);
+      m[k] = a;
+    }
+    m[k].push(x);
+  }
+
+  /* Sort each leaf array. */
+  if (this.order) {
+    for (var i = 0; i < values.length; i++) {
+      values[i].sort(this.order);
+    }
+  }
+
+  return map;
+};
+
+/**
+ * Returns a hierarchical nested array. This method is similar to
+ * {@link pv.entries}, but works recursively on the entire hierarchy. Rather
+ * than returning a map like {@link #map}, this method returns a nested
+ * array. Each element of the array has a <tt>key</tt> and <tt>values</tt>
+ * field. For leaf nodes, the <tt>values</tt> array will be a subset of the
+ * underlying elements array; for non-leaf nodes, the <tt>values</tt> array will
+ * contain more key-values pairs.
+ *
+ * <p>For an example usage, see the {@link Nest} constructor.
+ *
+ * @returns a hierarchical nested array.
+ */
+pv.Nest.prototype.entries = function() {
+
+  /** Recursively extracts the entries for the given map. */
+  function entries(map) {
+    var array = [];
+    for (var k in map) {
+      var v = map[k];
+      array.push({ key: k, values: (v instanceof Array) ? v : entries(v) });
+    };
+    return array;
+  }
+
+  /** Recursively sorts the values for the given key-values array. */
+  function sort(array, i) {
+    var o = this.keys[i].order;
+    if (o) array.sort(function(a, b) { return o(a.key, b.key); });
+    if (++i < this.keys.length) {
+      for (var j = 0; j < array.length; j++) {
+        sort.call(this, array[j].values, i);
+      }
+    }
+    return array;
+  }
+
+  return sort.call(this, entries(this.map()), 0);
+};
+
+/**
+ * Returns a rollup map. The behavior of this method is the same as
+ * {@link #map}, except that the leaf values are replaced with the return value
+ * of the specified rollup function <tt>f</tt>. For example,
+ *
+ * <pre>pv.nest(yields)
+ *      .key(function(d) d.site)
+ *      .rollup(function(v) pv.median(v, function(d) d.yield))</pre>
+ *
+ * first groups yield data by site, and then returns a map from site to median
+ * yield for the given site.
+ *
+ * @see #map
+ * @param {function} f a rollup function.
+ * @returns a hierarchical map, with the leaf values computed by <tt>f</tt>.
+ */
+pv.Nest.prototype.rollup = function(f) {
+
+  /** Recursively descends to the leaf nodes (arrays) and does rollup. */
+  function rollup(map) {
+    for (var key in map) {
+      var value = map[key];
+      if (value instanceof Array) {
+        map[key] = f(value);
+      } else {
+        rollup(value);
+      }
+    }
+    return map;
+  }
+
+  return rollup(this.map());
+};
diff --git a/vendor/protovis/src/data/Numbers.js b/vendor/protovis/src/data/Numbers.js
new file mode 100644
index 0000000..ec2e868
--- /dev/null
+++ b/vendor/protovis/src/data/Numbers.js
@@ -0,0 +1,313 @@
+/**
+ * Returns an array of numbers, starting at <tt>start</tt>, incrementing by
+ * <tt>step</tt>, until <tt>stop</tt> is reached. The stop value is
+ * exclusive. If only a single argument is specified, this value is interpeted
+ * as the <i>stop</i> value, with the <i>start</i> value as zero. If only two
+ * arguments are specified, the step value is implied to be one.
+ *
+ * <p>The method is modeled after the built-in <tt>range</tt> method from
+ * Python. See the Python documentation for more details.
+ *
+ * @see <a href="http://docs.python.org/library/functions.html#range">Python range</a>
+ * @param {number} [start] the start value.
+ * @param {number} stop the stop value.
+ * @param {number} [step] the step value.
+ * @returns {number[]} an array of numbers.
+ */
+pv.range = function(start, stop, step) {
+  if (arguments.length == 1) {
+    stop = start;
+    start = 0;
+  }
+  if (step == undefined) step = 1;
+  if ((stop - start) / step == Infinity) throw new Error("range must be finite");
+  var array = [], i = 0, j;
+  stop -= (stop - start) * 1e-10; // floating point precision!
+  if (step < 0) {
+    while ((j = start + step * i++) > stop) {
+      array.push(j);
+    }
+  } else {
+    while ((j = start + step * i++) < stop) {
+      array.push(j);
+    }
+  }
+  return array;
+};
+
+/**
+ * Returns a random number in the range [<tt>start</tt>, <tt>stop</tt>) that is
+ * a multiple of <tt>step</tt>. More specifically, the returned number is of the
+ * form <tt>start</tt> + <i>n</i> * <tt>step</tt>, where <i>n</i> is a
+ * nonnegative integer. If <tt>step</tt> is not specified, it defaults to 1,
+ * returning a random integer if <tt>start</tt> is also an integer.
+ *
+ * @param {number} [start] the start value value.
+ * @param {number} stop the stop value.
+ * @param {number} [step] the step value.
+ * @returns {number} a random number between <i>start</i> and <i>stop</i>.
+ */
+pv.random = function(start, stop, step) {
+  if (arguments.length == 1) {
+    stop = start;
+    start = 0;
+  }
+  if (step == undefined) step = 1;
+  return step
+      ? (Math.floor(Math.random() * (stop - start) / step) * step + start)
+      : (Math.random() * (stop - start) + start);
+};
+
+/**
+ * Returns the sum of the specified array. If the specified array is not an
+ * array of numbers, an optional accessor function <tt>f</tt> can be specified
+ * to map the elements to numbers. See {@link #normalize} for an example.
+ * Accessor functions can refer to <tt>this.index</tt>.
+ *
+ * @param {array} array an array of objects, or numbers.
+ * @param {function} [f] an optional accessor function.
+ * @returns {number} the sum of the specified array.
+ */
+pv.sum = function(array, f) {
+  var o = {};
+  return array.reduce(f
+      ? function(p, d, i) { o.index = i; return p + f.call(o, d); }
+      : function(p, d) { return p + d; }, 0);
+};
+
+/**
+ * Returns the maximum value of the specified array. If the specified array is
+ * not an array of numbers, an optional accessor function <tt>f</tt> can be
+ * specified to map the elements to numbers. See {@link #normalize} for an
+ * example. Accessor functions can refer to <tt>this.index</tt>.
+ *
+ * @param {array} array an array of objects, or numbers.
+ * @param {function} [f] an optional accessor function.
+ * @returns {number} the maximum value of the specified array.
+ */
+pv.max = function(array, f) {
+  if (f == pv.index) return array.length - 1;
+  return Math.max.apply(null, f ? pv.map(array, f) : array);
+};
+
+/**
+ * Returns the index of the maximum value of the specified array. If the
+ * specified array is not an array of numbers, an optional accessor function
+ * <tt>f</tt> can be specified to map the elements to numbers. See
+ * {@link #normalize} for an example. Accessor functions can refer to
+ * <tt>this.index</tt>.
+ *
+ * @param {array} array an array of objects, or numbers.
+ * @param {function} [f] an optional accessor function.
+ * @returns {number} the index of the maximum value of the specified array.
+ */
+pv.max.index = function(array, f) {
+  if (!array.length) return -1;
+  if (f == pv.index) return array.length - 1;
+  if (!f) f = pv.identity;
+  var maxi = 0, maxx = -Infinity, o = {};
+  for (var i = 0; i < array.length; i++) {
+    o.index = i;
+    var x = f.call(o, array[i]);
+    if (x > maxx) {
+      maxx = x;
+      maxi = i;
+    }
+  }
+  return maxi;
+}
+
+/**
+ * Returns the minimum value of the specified array of numbers. If the specified
+ * array is not an array of numbers, an optional accessor function <tt>f</tt>
+ * can be specified to map the elements to numbers. See {@link #normalize} for
+ * an example. Accessor functions can refer to <tt>this.index</tt>.
+ *
+ * @param {array} array an array of objects, or numbers.
+ * @param {function} [f] an optional accessor function.
+ * @returns {number} the minimum value of the specified array.
+ */
+pv.min = function(array, f) {
+  if (f == pv.index) return 0;
+  return Math.min.apply(null, f ? pv.map(array, f) : array);
+};
+
+/**
+ * Returns the index of the minimum value of the specified array. If the
+ * specified array is not an array of numbers, an optional accessor function
+ * <tt>f</tt> can be specified to map the elements to numbers. See
+ * {@link #normalize} for an example. Accessor functions can refer to
+ * <tt>this.index</tt>.
+ *
+ * @param {array} array an array of objects, or numbers.
+ * @param {function} [f] an optional accessor function.
+ * @returns {number} the index of the minimum value of the specified array.
+ */
+pv.min.index = function(array, f) {
+  if (!array.length) return -1;
+  if (f == pv.index) return 0;
+  if (!f) f = pv.identity;
+  var mini = 0, minx = Infinity, o = {};
+  for (var i = 0; i < array.length; i++) {
+    o.index = i;
+    var x = f.call(o, array[i]);
+    if (x < minx) {
+      minx = x;
+      mini = i;
+    }
+  }
+  return mini;
+}
+
+/**
+ * Returns the arithmetic mean, or average, of the specified array. If the
+ * specified array is not an array of numbers, an optional accessor function
+ * <tt>f</tt> can be specified to map the elements to numbers. See
+ * {@link #normalize} for an example. Accessor functions can refer to
+ * <tt>this.index</tt>.
+ *
+ * @param {array} array an array of objects, or numbers.
+ * @param {function} [f] an optional accessor function.
+ * @returns {number} the mean of the specified array.
+ */
+pv.mean = function(array, f) {
+  return pv.sum(array, f) / array.length;
+};
+
+/**
+ * Returns the median of the specified array. If the specified array is not an
+ * array of numbers, an optional accessor function <tt>f</tt> can be specified
+ * to map the elements to numbers. See {@link #normalize} for an example.
+ * Accessor functions can refer to <tt>this.index</tt>.
+ *
+ * @param {array} array an array of objects, or numbers.
+ * @param {function} [f] an optional accessor function.
+ * @returns {number} the median of the specified array.
+ */
+pv.median = function(array, f) {
+  if (f == pv.index) return (array.length - 1) / 2;
+  array = pv.map(array, f).sort(pv.naturalOrder);
+  if (array.length % 2) return array[Math.floor(array.length / 2)];
+  var i = array.length / 2;
+  return (array[i - 1] + array[i]) / 2;
+};
+
+/**
+ * Returns the unweighted variance of the specified array. If the specified
+ * array is not an array of numbers, an optional accessor function <tt>f</tt>
+ * can be specified to map the elements to numbers. See {@link #normalize} for
+ * an example. Accessor functions can refer to <tt>this.index</tt>.
+ *
+ * @param {array} array an array of objects, or numbers.
+ * @param {function} [f] an optional accessor function.
+ * @returns {number} the variance of the specified array.
+ */
+pv.variance = function(array, f) {
+  if (array.length < 1) return NaN;
+  if (array.length == 1) return 0;
+  var mean = pv.mean(array, f), sum = 0, o = {};
+  if (!f) f = pv.identity;
+  for (var i = 0; i < array.length; i++) {
+    o.index = i;
+    var d = f.call(o, array[i]) - mean;
+    sum += d * d;
+  }
+  return sum;
+};
+
+/**
+ * Returns an unbiased estimation of the standard deviation of a population,
+ * given the specified random sample. If the specified array is not an array of
+ * numbers, an optional accessor function <tt>f</tt> can be specified to map the
+ * elements to numbers. See {@link #normalize} for an example. Accessor
+ * functions can refer to <tt>this.index</tt>.
+ *
+ * @param {array} array an array of objects, or numbers.
+ * @param {function} [f] an optional accessor function.
+ * @returns {number} the standard deviation of the specified array.
+ */
+pv.deviation = function(array, f) {
+  return Math.sqrt(pv.variance(array, f) / (array.length - 1));
+};
+
+/**
+ * Returns the logarithm with a given base value.
+ *
+ * @param {number} x the number for which to compute the logarithm.
+ * @param {number} b the base of the logarithm.
+ * @returns {number} the logarithm value.
+ */
+pv.log = function(x, b) {
+  return Math.log(x) / Math.log(b);
+};
+
+/**
+ * Computes a zero-symmetric logarithm. Computes the logarithm of the absolute
+ * value of the input, and determines the sign of the output according to the
+ * sign of the input value.
+ *
+ * @param {number} x the number for which to compute the logarithm.
+ * @param {number} b the base of the logarithm.
+ * @returns {number} the symmetric log value.
+ */
+pv.logSymmetric = function(x, b) {
+  return (x == 0) ? 0 : ((x < 0) ? -pv.log(-x, b) : pv.log(x, b));
+};
+
+/**
+ * Computes a zero-symmetric logarithm, with adjustment to values between zero
+ * and the logarithm base. This adjustment introduces distortion for values less
+ * than the base number, but enables simultaneous plotting of log-transformed
+ * data involving both positive and negative numbers.
+ *
+ * @param {number} x the number for which to compute the logarithm.
+ * @param {number} b the base of the logarithm.
+ * @returns {number} the adjusted, symmetric log value.
+ */
+pv.logAdjusted = function(x, b) {
+  if (!isFinite(x)) return x;
+  var negative = x < 0;
+  if (x < b) x += (b - x) / b;
+  return negative ? -pv.log(x, b) : pv.log(x, b);
+};
+
+/**
+ * Rounds an input value down according to its logarithm. The method takes the
+ * floor of the logarithm of the value and then uses the resulting value as an
+ * exponent for the base value.
+ *
+ * @param {number} x the number for which to compute the logarithm floor.
+ * @param {number} b the base of the logarithm.
+ * @returns {number} the rounded-by-logarithm value.
+ */
+pv.logFloor = function(x, b) {
+  return (x > 0)
+      ? Math.pow(b, Math.floor(pv.log(x, b)))
+      : -Math.pow(b, -Math.floor(-pv.log(-x, b)));
+};
+
+/**
+ * Rounds an input value up according to its logarithm. The method takes the
+ * ceiling of the logarithm of the value and then uses the resulting value as an
+ * exponent for the base value.
+ *
+ * @param {number} x the number for which to compute the logarithm ceiling.
+ * @param {number} b the base of the logarithm.
+ * @returns {number} the rounded-by-logarithm value.
+ */
+pv.logCeil = function(x, b) {
+  return (x > 0)
+      ? Math.pow(b, Math.ceil(pv.log(x, b)))
+      : -Math.pow(b, -Math.ceil(-pv.log(-x, b)));
+};
+
+(function() {
+  var radians = Math.PI / 180,
+      degrees = 180 / Math.PI;
+
+  /** Returns the number of radians corresponding to the specified degrees. */
+  pv.radians = function(degrees) { return radians * degrees; };
+
+  /** Returns the number of degrees corresponding to the specified radians. */
+  pv.degrees = function(radians) { return degrees * radians; };
+})();
diff --git a/vendor/protovis/src/data/Objects.js b/vendor/protovis/src/data/Objects.js
new file mode 100644
index 0000000..5ff9435
--- /dev/null
+++ b/vendor/protovis/src/data/Objects.js
@@ -0,0 +1,78 @@
+/**
+ * Returns all of the property names (keys) of the specified object (a map). The
+ * order of the returned array is not defined.
+ *
+ * @param map an object.
+ * @returns {string[]} an array of strings corresponding to the keys.
+ * @see #entries
+ */
+pv.keys = function(map) {
+  var array = [];
+  for (var key in map) {
+    array.push(key);
+  }
+  return array;
+};
+
+/**
+ * Returns all of the entries (key-value pairs) of the specified object (a
+ * map). The order of the returned array is not defined. Each key-value pair is
+ * represented as an object with <tt>key</tt> and <tt>value</tt> attributes,
+ * e.g., <tt>{key: "foo", value: 42}</tt>.
+ *
+ * @param map an object.
+ * @returns {array} an array of key-value pairs corresponding to the keys.
+ */
+pv.entries = function(map) {
+  var array = [];
+  for (var key in map) {
+    array.push({ key: key, value: map[key] });
+  }
+  return array;
+};
+
+/**
+ * Returns all of the values (attribute values) of the specified object (a
+ * map). The order of the returned array is not defined.
+ *
+ * @param map an object.
+ * @returns {array} an array of objects corresponding to the values.
+ * @see #entries
+ */
+pv.values = function(map) {
+  var array = [];
+  for (var key in map) {
+    array.push(map[key]);
+  }
+  return array;
+};
+
+/**
+ * Returns a map constructed from the specified <tt>keys</tt>, using the
+ * function <tt>f</tt> to compute the value for each key. The single argument to
+ * the value function is the key. The callback is invoked only for indexes of
+ * the array which have assigned values; it is not invoked for indexes which
+ * have been deleted or which have never been assigned values.
+ *
+ * <p>For example, this expression creates a map from strings to string length:
+ *
+ * <pre>pv.dict(["one", "three", "seventeen"], function(s) s.length)</pre>
+ *
+ * The returned value is <tt>{one: 3, three: 5, seventeen: 9}</tt>. Accessor
+ * functions can refer to <tt>this.index</tt>.
+ *
+ * @param {array} keys an array.
+ * @param {function} f a value function.
+ * @returns a map from keys to values.
+ */
+pv.dict = function(keys, f) {
+  var m = {}, o = {};
+  for (var i = 0; i < keys.length; i++) {
+    if (i in keys) {
+      var k = keys[i];
+      o.index = i;
+      m[k] = f.call(o, k);
+    }
+  }
+  return m;
+};
diff --git a/vendor/protovis/src/data/OrdinalScale.js b/vendor/protovis/src/data/OrdinalScale.js
new file mode 100644
index 0000000..917ec18
--- /dev/null
+++ b/vendor/protovis/src/data/OrdinalScale.js
@@ -0,0 +1,267 @@
+/**
+ * Returns an ordinal scale for the specified domain. The arguments to this
+ * constructor are optional, and equivalent to calling {@link #domain}.
+ *
+ * @class Represents an ordinal scale. <style
+ * type="text/css">sub{line-height:0}</style> An ordinal scale represents a
+ * pairwise mapping from <i>n</i> discrete values in the input domain to
+ * <i>n</i> discrete values in the output range. For example, an ordinal scale
+ * might map a domain of species ["setosa", "versicolor", "virginica"] to colors
+ * ["red", "green", "blue"]. Thus, saying
+ *
+ * <pre>    .fillStyle(function(d) {
+ *         switch (d.species) {
+ *           case "setosa": return "red";
+ *           case "versicolor": return "green";
+ *           case "virginica": return "blue";
+ *         }
+ *       })</pre>
+ *
+ * is equivalent to
+ *
+ * <pre>    .fillStyle(pv.Scale.ordinal("setosa", "versicolor", "virginica")
+ *         .range("red", "green", "blue")
+ *         .by(function(d) d.species))</pre>
+ *
+ * If the mapping from species to color does not need to be specified
+ * explicitly, the domain can be omitted. In this case it will be inferred
+ * lazily from the data:
+ *
+ * <pre>    .fillStyle(pv.colors("red", "green", "blue")
+ *         .by(function(d) d.species))</pre>
+ *
+ * When the domain is inferred, the first time the scale is invoked, the first
+ * element from the range will be returned. Subsequent calls with unique values
+ * will return subsequent elements from the range. If the inferred domain grows
+ * larger than the range, range values will be reused. However, it is strongly
+ * recommended that the domain and the range contain the same number of
+ * elements.
+ *
+ * <p>A range can be discretized from a continuous interval (e.g., for pixel
+ * positioning) by using {@link #split}, {@link #splitFlush} or
+ * {@link #splitBanded} after the domain has been set. For example, if
+ * <tt>states</tt> is an array of the fifty U.S. state names, the state name can
+ * be encoded in the left position:
+ *
+ * <pre>    .left(pv.Scale.ordinal(states)
+ *         .split(0, 640)
+ *         .by(function(d) d.state))</pre>
+ *
+ * <p>N.B.: ordinal scales are not invertible (at least not yet), since the
+ * domain and range and discontinuous. A workaround is to use a linear scale.
+ *
+ * @param {...} domain... optional domain values.
+ * @extends pv.Scale
+ * @see pv.colors
+ */
+pv.Scale.ordinal = function() {
+  var d = [], i = {}, r = [], band = 0;
+
+  /** @private */
+  function scale(x) {
+    if (!(x in i)) i[x] = d.push(x) - 1;
+    return r[i[x] % r.length];
+  }
+
+  /**
+   * Sets or gets the input domain. This method can be invoked several ways:
+   *
+   * <p>1. <tt>domain(values...)</tt>
+   *
+   * <p>Specifying the domain as a series of values is the most explicit and
+   * recommended approach. However, if the domain values are derived from data,
+   * you may find the second method more appropriate.
+   *
+   * <p>2. <tt>domain(array, f)</tt>
+   *
+   * <p>Rather than enumerating the domain values as explicit arguments to this
+   * method, you can specify a single argument of an array. In addition, you can
+   * specify an optional accessor function to extract the domain values from the
+   * array.
+   *
+   * <p>3. <tt>domain()</tt>
+   *
+   * <p>Invoking the <tt>domain</tt> method with no arguments returns the
+   * current domain as an array.
+   *
+   * @function
+   * @name pv.Scale.ordinal.prototype.domain
+   * @param {...} domain... domain values.
+   * @returns {pv.Scale.ordinal} <tt>this</tt>, or the current domain.
+   */
+  scale.domain = function(array, f) {
+    if (arguments.length) {
+      array = (array instanceof Array)
+          ? ((arguments.length > 1) ? pv.map(array, f) : array)
+          : Array.prototype.slice.call(arguments);
+
+      /* Filter the specified ordinals to their unique values. */
+      d = [];
+      var seen = {};
+      for (var j = 0; j < array.length; j++) {
+        var o = array[j];
+        if (!(o in seen)) {
+          seen[o] = true;
+          d.push(o);
+        }
+      }
+
+      i = pv.numerate(d);
+      return this;
+    }
+    return d;
+  };
+
+  /**
+   * Sets or gets the output range. This method can be invoked several ways:
+   *
+   * <p>1. <tt>range(values...)</tt>
+   *
+   * <p>Specifying the range as a series of values is the most explicit and
+   * recommended approach. However, if the range values are derived from data,
+   * you may find the second method more appropriate.
+   *
+   * <p>2. <tt>range(array, f)</tt>
+   *
+   * <p>Rather than enumerating the range values as explicit arguments to this
+   * method, you can specify a single argument of an array. In addition, you can
+   * specify an optional accessor function to extract the range values from the
+   * array.
+   *
+   * <p>3. <tt>range()</tt>
+   *
+   * <p>Invoking the <tt>range</tt> method with no arguments returns the
+   * current range as an array.
+   *
+   * @function
+   * @name pv.Scale.ordinal.prototype.range
+   * @param {...} range... range values.
+   * @returns {pv.Scale.ordinal} <tt>this</tt>, or the current range.
+   */
+  scale.range = function(array, f) {
+    if (arguments.length) {
+      r = (array instanceof Array)
+          ? ((arguments.length > 1) ? pv.map(array, f) : array)
+          : Array.prototype.slice.call(arguments);
+      if (typeof r[0] == "string") r = r.map(pv.color);
+      return this;
+    }
+    return r;
+  };
+
+  /**
+   * Sets the range from the given continuous interval. The interval
+   * [<i>min</i>, <i>max</i>] is subdivided into <i>n</i> equispaced points,
+   * where <i>n</i> is the number of (unique) values in the domain. The first
+   * and last point are offset from the edge of the range by half the distance
+   * between points.
+   *
+   * <p>This method must be called <i>after</i> the domain is set.
+   *
+   * @function
+   * @name pv.Scale.ordinal.prototype.split
+   * @param {number} min minimum value of the output range.
+   * @param {number} max maximum value of the output range.
+   * @returns {pv.Scale.ordinal} <tt>this</tt>.
+   * @see #splitFlush
+   * @see #splitBanded
+   */
+  scale.split = function(min, max) {
+    var step = (max - min) / this.domain().length;
+    r = pv.range(min + step / 2, max, step);
+    return this;
+  };
+
+  /**
+   * Sets the range from the given continuous interval. The interval
+   * [<i>min</i>, <i>max</i>] is subdivided into <i>n</i> equispaced points,
+   * where <i>n</i> is the number of (unique) values in the domain. The first
+   * and last point are exactly on the edge of the range.
+   *
+   * <p>This method must be called <i>after</i> the domain is set.
+   *
+   * @function
+   * @name pv.Scale.ordinal.prototype.splitFlush
+   * @param {number} min minimum value of the output range.
+   * @param {number} max maximum value of the output range.
+   * @returns {pv.Scale.ordinal} <tt>this</tt>.
+   * @see #split
+   */
+  scale.splitFlush = function(min, max) {
+    var n = this.domain().length, step = (max - min) / (n - 1);
+    r = (n == 1) ? [(min + max) / 2]
+        : pv.range(min, max + step / 2, step);
+    return this;
+  };
+
+  /**
+   * Sets the range from the given continuous interval. The interval
+   * [<i>min</i>, <i>max</i>] is subdivided into <i>n</i> equispaced bands,
+   * where <i>n</i> is the number of (unique) values in the domain. The first
+   * and last band are offset from the edge of the range by the distance between
+   * bands.
+   *
+   * <p>The band width argument, <tt>band</tt>, is typically in the range [0, 1]
+   * and defaults to 1. This fraction corresponds to the amount of space in the
+   * range to allocate to the bands, as opposed to padding. A value of 0.5 means
+   * that the band width will be equal to the padding width. The computed
+   * absolute band width can be retrieved from the range as
+   * <tt>scale.range().band</tt>.
+   *
+   * <p>If the band width argument is negative, this method will allocate bands
+   * of a <i>fixed</i> width <tt>-band</tt>, rather than a relative fraction of
+   * the available space.
+   *
+   * <p>Tip: to inset the bands by a fixed amount <tt>p</tt>, specify a minimum
+   * value of <tt>min + p</tt> (or simply <tt>p</tt>, if <tt>min</tt> is
+   * 0). Then set the mark width to <tt>scale.range().band - p</tt>.
+   *
+   * <p>This method must be called <i>after</i> the domain is set.
+   *
+   * @function
+   * @name pv.Scale.ordinal.prototype.splitBanded
+   * @param {number} min minimum value of the output range.
+   * @param {number} max maximum value of the output range.
+   * @param {number} [band] the fractional band width in [0, 1]; defaults to 1.
+   * @returns {pv.Scale.ordinal} <tt>this</tt>.
+   * @see #split
+   */
+  scale.splitBanded = function(min, max, band) {
+    if (arguments.length < 3) band = 1;
+    if (band < 0) {
+      var n = this.domain().length,
+          total = -band * n,
+          remaining = max - min - total,
+          padding = remaining / (n + 1);
+      r = pv.range(min + padding, max, padding - band);
+      r.band = -band;
+    } else {
+      var step = (max - min) / (this.domain().length + (1 - band));
+      r = pv.range(min + step * (1 - band), max, step);
+      r.band = step * band;
+    }
+    return this;
+  };
+
+  /**
+   * Returns a view of this scale by the specified accessor function <tt>f</tt>.
+   * Given a scale <tt>y</tt>, <tt>y.by(function(d) d.foo)</tt> is equivalent to
+   * <tt>function(d) y(d.foo)</tt>. This method should be used judiciously; it
+   * is typically more clear to invoke the scale directly, passing in the value
+   * to be scaled.
+   *
+   * @function
+   * @name pv.Scale.ordinal.prototype.by
+   * @param {function} f an accessor function.
+   * @returns {pv.Scale.ordinal} a view of this scale by the specified accessor
+   * function.
+   */
+  scale.by = function(f) {
+    function by() { return scale(f.apply(this, arguments)); }
+    for (var method in scale) by[method] = scale[method];
+    return by;
+  };
+
+  scale.domain.apply(scale, arguments);
+  return scale;
+};
diff --git a/vendor/protovis/src/data/QuantileScale.js b/vendor/protovis/src/data/QuantileScale.js
new file mode 100644
index 0000000..9eede71
--- /dev/null
+++ b/vendor/protovis/src/data/QuantileScale.js
@@ -0,0 +1,180 @@
+/**
+ * Constructs a default quantile scale. The arguments to this constructor are
+ * optional, and equivalent to calling {@link #domain}. The default domain is
+ * the empty set, and the default range is [0,1].
+ *
+ * @class Represents a quantile scale; a function that maps from a value within
+ * a sortable domain to a quantized numeric range. Typically, the domain is a
+ * set of numbers, but any sortable value (such as strings) can be used as the
+ * domain of a quantile scale. The range defaults to [0,1], with 0 corresponding
+ * to the smallest value in the domain, 1 the largest, .5 the median, etc.
+ *
+ * <p>By default, the number of quantiles in the range corresponds to the number
+ * of values in the domain. The {@link #quantiles} method can be used to specify
+ * an explicit number of quantiles; for example, <tt>quantiles(4)</tt> produces
+ * a standard quartile scale. A quartile scale's range is a set of four discrete
+ * values, such as [0, 1/3, 2/3, 1]. Calling the {@link #range} method will
+ * scale these discrete values accordingly, similar to {@link
+ * pv.Scale.ordinal#splitFlush}.
+ *
+ * <p>For example, given the strings ["c", "a", "b"], a default quantile scale:
+ *
+ * <pre>pv.Scale.quantile("c", "a", "b")</pre>
+ *
+ * will return 0 for "a", .5 for "b", and 1 for "c".
+ *
+ * @extends pv.Scale
+ */
+pv.Scale.quantile = function() {
+  var n = -1, // number of quantiles
+      j = -1, // max quantile index
+      q = [], // quantile boundaries
+      d = [], // domain
+      y = pv.Scale.linear(); // range
+
+  /** @private */
+  function scale(x) {
+    return y(Math.max(0, Math.min(j, pv.search.index(q, x) - 1)) / j);
+  }
+
+  /**
+   * Sets or gets the quantile boundaries. By default, each element in the
+   * domain is in its own quantile. If the argument to this method is a number,
+   * it specifies the number of equal-sized quantiles by which to divide the
+   * domain.
+   *
+   * <p>If no arguments are specified, this method returns the quantile
+   * boundaries; the first element is always the minimum value of the domain,
+   * and the last element is the maximum value of the domain. Thus, the length
+   * of the returned array is always one greater than the number of quantiles.
+   *
+   * @function
+   * @name pv.Scale.quantile.prototype.quantiles
+   * @param {number} x the number of quantiles.
+   */
+  scale.quantiles = function(x) {
+    if (arguments.length) {
+      n = Number(x);
+      if (n < 0) {
+        q = [d[0]].concat(d);
+        j = d.length - 1;
+      } else {
+        q = [];
+        q[0] = d[0];
+        for (var i = 1; i <= n; i++) {
+          q[i] = d[~~(i * (d.length - 1) / n)];
+        }
+        j = n - 1;
+      }
+      return this;
+    }
+    return q;
+  };
+
+  /**
+   * Sets or gets the input domain. This method can be invoked several ways:
+   *
+   * <p>1. <tt>domain(values...)</tt>
+   *
+   * <p>Specifying the domain as a series of values is the most explicit and
+   * recommended approach. However, if the domain values are derived from data,
+   * you may find the second method more appropriate.
+   *
+   * <p>2. <tt>domain(array, f)</tt>
+   *
+   * <p>Rather than enumerating the domain values as explicit arguments to this
+   * method, you can specify a single argument of an array. In addition, you can
+   * specify an optional accessor function to extract the domain values from the
+   * array.
+   *
+   * <p>3. <tt>domain()</tt>
+   *
+   * <p>Invoking the <tt>domain</tt> method with no arguments returns the
+   * current domain as an array.
+   *
+   * @function
+   * @name pv.Scale.quantile.prototype.domain
+   * @param {...} domain... domain values.
+   * @returns {pv.Scale.quantile} <tt>this</tt>, or the current domain.
+   */
+  scale.domain = function(array, f) {
+    if (arguments.length) {
+      d = (array instanceof Array)
+          ? pv.map(array, f)
+          : Array.prototype.slice.call(arguments);
+      d.sort(pv.naturalOrder);
+      scale.quantiles(n); // recompute quantiles
+      return this;
+    }
+    return d;
+  };
+
+  /**
+   * Sets or gets the output range. This method can be invoked several ways:
+   *
+   * <p>1. <tt>range(min, ..., max)</tt>
+   *
+   * <p>The range may be specified as a series of numbers or colors. Most
+   * commonly, two numbers are specified: the minimum and maximum pixel values.
+   * For a color scale, values may be specified as {@link pv.Color}s or
+   * equivalent strings. For a diverging scale, or other subdivided non-uniform
+   * scales, multiple values can be specified. For example:
+   *
+   * <pre>    .range("red", "white", "green")</pre>
+   *
+   * <p>Currently, only numbers and colors are supported as range values. The
+   * number of range values must exactly match the number of domain values, or
+   * the behavior of the scale is undefined.
+   *
+   * <p>2. <tt>range()</tt>
+   *
+   * <p>Invoking the <tt>range</tt> method with no arguments returns the current
+   * range as an array of numbers or colors.
+   *
+   * @function
+   * @name pv.Scale.quantile.prototype.range
+   * @param {...} range... range values.
+   * @returns {pv.Scale.quantile} <tt>this</tt>, or the current range.
+   */
+  scale.range = function() {
+    if (arguments.length) {
+      y.range.apply(y, arguments);
+      return this;
+    }
+    return y.range();
+  };
+
+  /**
+   * Returns a view of this scale by the specified accessor function <tt>f</tt>.
+   * Given a scale <tt>y</tt>, <tt>y.by(function(d) d.foo)</tt> is equivalent to
+   * <tt>function(d) y(d.foo)</tt>.
+   *
+   * <p>This method is provided for convenience, such that scales can be
+   * succinctly defined inline. For example, given an array of data elements
+   * that have a <tt>score</tt> attribute with the domain [0, 1], the height
+   * property could be specified as:
+   *
+   * <pre>.height(pv.Scale.linear().range(0, 480).by(function(d) d.score))</pre>
+   *
+   * This is equivalent to:
+   *
+   * <pre>.height(function(d) d.score * 480)</pre>
+   *
+   * This method should be used judiciously; it is typically more clear to
+   * invoke the scale directly, passing in the value to be scaled.
+   *
+   * @function
+   * @name pv.Scale.quantile.prototype.by
+   * @param {function} f an accessor function.
+   * @returns {pv.Scale.quantile} a view of this scale by the specified
+   * accessor function.
+   */
+  scale.by = function(f) {
+    function by() { return scale(f.apply(this, arguments)); }
+    for (var method in scale) by[method] = scale[method];
+    return by;
+  };
+
+  scale.domain.apply(scale, arguments);
+  return scale;
+};
diff --git a/vendor/protovis/src/data/QuantitativeScale.js b/vendor/protovis/src/data/QuantitativeScale.js
new file mode 100644
index 0000000..48f4979
--- /dev/null
+++ b/vendor/protovis/src/data/QuantitativeScale.js
@@ -0,0 +1,440 @@
+/**
+ * Returns a default quantitative, linear, scale for the specified domain. The
+ * arguments to this constructor are optional, and equivalent to calling
+ * {@link #domain}. The default domain and range are [0,1].
+ *
+ * <p>This constructor is typically not used directly; see one of the
+ * quantitative scale implementations instead.
+ *
+ * @class Represents an abstract quantitative scale; a function that performs a
+ * numeric transformation. This class is typically not used directly; see one of
+ * the quantitative scale implementations (linear, log, root, etc.)
+ * instead. <style type="text/css">sub{line-height:0}</style> A quantitative
+ * scale represents a 1-dimensional transformation from a numeric domain of
+ * input data [<i>d<sub>0</sub></i>, <i>d<sub>1</sub></i>] to a numeric range of
+ * pixels [<i>r<sub>0</sub></i>, <i>r<sub>1</sub></i>]. In addition to
+ * readability, scales offer several useful features:
+ *
+ * <p>1. The range can be expressed in colors, rather than pixels. For example:
+ *
+ * <pre>    .fillStyle(pv.Scale.linear(0, 100).range("red", "green"))</pre>
+ *
+ * will fill the marks "red" on an input value of 0, "green" on an input value
+ * of 100, and some color in-between for intermediate values.
+ *
+ * <p>2. The domain and range can be subdivided for a non-uniform
+ * transformation. For example, you may want a diverging color scale that is
+ * increasingly red for negative values, and increasingly green for positive
+ * values:
+ *
+ * <pre>    .fillStyle(pv.Scale.linear(-1, 0, 1).range("red", "white", "green"))</pre>
+ *
+ * The domain can be specified as a series of <i>n</i> monotonically-increasing
+ * values; the range must also be specified as <i>n</i> values, resulting in
+ * <i>n - 1</i> contiguous linear scales.
+ *
+ * <p>3. Quantitative scales can be inverted for interaction. The
+ * {@link #invert} method takes a value in the output range, and returns the
+ * corresponding value in the input domain. This is frequently used to convert
+ * the mouse location (see {@link pv.Mark#mouse}) to a value in the input
+ * domain. Note that inversion is only supported for numeric ranges, and not
+ * colors.
+ *
+ * <p>4. A scale can be queried for reasonable "tick" values. The {@link #ticks}
+ * method provides a convenient way to get a series of evenly-spaced rounded
+ * values in the input domain. Frequently these are used in conjunction with
+ * {@link pv.Rule} to display tick marks or grid lines.
+ *
+ * <p>5. A scale can be "niced" to extend the domain to suitable rounded
+ * numbers. If the minimum and maximum of the domain are messy because they are
+ * derived from data, you can use {@link #nice} to round these values down and
+ * up to even numbers.
+ *
+ * @param {number...} domain... optional domain values.
+ * @see pv.Scale.linear
+ * @see pv.Scale.log
+ * @see pv.Scale.root
+ * @extends pv.Scale
+ */
+pv.Scale.quantitative = function() {
+  var d = [0, 1], // default domain
+      l = [0, 1], // default transformed domain
+      r = [0, 1], // default range
+      i = [pv.identity], // default interpolators
+      type = Number, // default type
+      n = false, // whether the domain is negative
+      f = pv.identity, // default forward transform
+      g = pv.identity, // default inverse transform
+      tickFormat = String; // default tick formatting function
+
+  /** @private */
+  function newDate(x) {
+    return new Date(x);
+  }
+
+  /** @private */
+  function scale(x) {
+    var j = pv.search(d, x);
+    if (j < 0) j = -j - 2;
+    j = Math.max(0, Math.min(i.length - 1, j));
+    return i[j]((f(x) - l[j]) / (l[j + 1] - l[j]));
+  }
+
+  /** @private */
+  scale.transform = function(forward, inverse) {
+    /** @ignore */ f = function(x) { return n ? -forward(-x) : forward(x); };
+    /** @ignore */ g = function(y) { return n ? -inverse(-y) : inverse(y); };
+    l = d.map(f);
+    return this;
+  };
+
+  /**
+   * Sets or gets the input domain. This method can be invoked several ways:
+   *
+   * <p>1. <tt>domain(min, ..., max)</tt>
+   *
+   * <p>Specifying the domain as a series of numbers is the most explicit and
+   * recommended approach. Most commonly, two numbers are specified: the minimum
+   * and maximum value. However, for a diverging scale, or other subdivided
+   * non-uniform scales, multiple values can be specified. Values can be derived
+   * from data using {@link pv.min} and {@link pv.max}. For example:
+   *
+   * <pre>    .domain(0, pv.max(array))</pre>
+   *
+   * An alternative method for deriving minimum and maximum values from data
+   * follows.
+   *
+   * <p>2. <tt>domain(array, minf, maxf)</tt>
+   *
+   * <p>When both the minimum and maximum value are derived from data, the
+   * arguments to the <tt>domain</tt> method can be specified as the array of
+   * data, followed by zero, one or two accessor functions. For example, if the
+   * array of data is just an array of numbers:
+   *
+   * <pre>    .domain(array)</pre>
+   *
+   * On the other hand, if the array elements are objects representing stock
+   * values per day, and the domain should consider the stock's daily low and
+   * daily high:
+   *
+   * <pre>    .domain(array, function(d) d.low, function(d) d.high)</pre>
+   *
+   * The first method of setting the domain is preferred because it is more
+   * explicit; setting the domain using this second method should be used only
+   * if brevity is required.
+   *
+   * <p>3. <tt>domain()</tt>
+   *
+   * <p>Invoking the <tt>domain</tt> method with no arguments returns the
+   * current domain as an array of numbers.
+   *
+   * @function
+   * @name pv.Scale.quantitative.prototype.domain
+   * @param {number...} domain... domain values.
+   * @returns {pv.Scale.quantitative} <tt>this</tt>, or the current domain.
+   */
+  scale.domain = function(array, min, max) {
+    if (arguments.length) {
+      var o; // the object we use to infer the domain type
+      if (array instanceof Array) {
+        if (arguments.length < 2) min = pv.identity;
+        if (arguments.length < 3) max = min;
+        o = array.length && min(array[0]);
+        d = array.length ? [pv.min(array, min), pv.max(array, max)] : [];
+      } else {
+        o = array;
+        d = Array.prototype.slice.call(arguments).map(Number);
+      }
+      if (!d.length) d = [-Infinity, Infinity];
+      else if (d.length == 1) d = [d[0], d[0]];
+      n = (d[0] || d[d.length - 1]) < 0;
+      l = d.map(f);
+      type = (o instanceof Date) ? newDate : Number;
+      return this;
+    }
+    return d.map(type);
+  };
+
+  /**
+   * Sets or gets the output range. This method can be invoked several ways:
+   *
+   * <p>1. <tt>range(min, ..., max)</tt>
+   *
+   * <p>The range may be specified as a series of numbers or colors. Most
+   * commonly, two numbers are specified: the minimum and maximum pixel values.
+   * For a color scale, values may be specified as {@link pv.Color}s or
+   * equivalent strings. For a diverging scale, or other subdivided non-uniform
+   * scales, multiple values can be specified. For example:
+   *
+   * <pre>    .range("red", "white", "green")</pre>
+   *
+   * <p>Currently, only numbers and colors are supported as range values. The
+   * number of range values must exactly match the number of domain values, or
+   * the behavior of the scale is undefined.
+   *
+   * <p>2. <tt>range()</tt>
+   *
+   * <p>Invoking the <tt>range</tt> method with no arguments returns the current
+   * range as an array of numbers or colors.
+   *
+   * @function
+   * @name pv.Scale.quantitative.prototype.range
+   * @param {...} range... range values.
+   * @returns {pv.Scale.quantitative} <tt>this</tt>, or the current range.
+   */
+  scale.range = function() {
+    if (arguments.length) {
+      r = Array.prototype.slice.call(arguments);
+      if (!r.length) r = [-Infinity, Infinity];
+      else if (r.length == 1) r = [r[0], r[0]];
+      i = [];
+      for (var j = 0; j < r.length - 1; j++) {
+        i.push(pv.Scale.interpolator(r[j], r[j + 1]));
+      }
+      return this;
+    }
+    return r;
+  };
+
+  /**
+   * Inverts the specified value in the output range, returning the
+   * corresponding value in the input domain. This is frequently used to convert
+   * the mouse location (see {@link pv.Mark#mouse}) to a value in the input
+   * domain. Inversion is only supported for numeric ranges, and not colors.
+   *
+   * <p>Note that this method does not do any rounding or bounds checking. If
+   * the input domain is discrete (e.g., an array index), the returned value
+   * should be rounded. If the specified <tt>y</tt> value is outside the range,
+   * the returned value may be equivalently outside the input domain.
+   *
+   * @function
+   * @name pv.Scale.quantitative.prototype.invert
+   * @param {number} y a value in the output range (a pixel location).
+   * @returns {number} a value in the input domain.
+   */
+  scale.invert = function(y) {
+    var j = pv.search(r, y);
+    if (j < 0) j = -j - 2;
+    j = Math.max(0, Math.min(i.length - 1, j));
+    return type(g(l[j] + (y - r[j]) / (r[j + 1] - r[j]) * (l[j + 1] - l[j])));
+  };
+
+  /**
+   * Returns an array of evenly-spaced, suitably-rounded values in the input
+   * domain. This method attempts to return between 5 and 10 tick values. These
+   * values are frequently used in conjunction with {@link pv.Rule} to display
+   * tick marks or grid lines.
+   *
+   * @function
+   * @name pv.Scale.quantitative.prototype.ticks
+   * @param {number} [m] optional number of desired ticks.
+   * @returns {number[]} an array input domain values to use as ticks.
+   */
+  scale.ticks = function(m) {
+    var start = d[0],
+        end = d[d.length - 1],
+        reverse = end < start,
+        min = reverse ? end : start,
+        max = reverse ? start : end,
+        span = max - min;
+
+    /* Special case: empty, invalid or infinite span. */
+    if (!span || !isFinite(span)) {
+      if (type == newDate) tickFormat = pv.Format.date("%x");
+      return [type(min)];
+    }
+
+    /* Special case: dates. */
+    if (type == newDate) {
+      /* Floor the date d given the precision p. */
+      function floor(d, p) {
+        switch (p) {
+          case 31536e6: d.setMonth(0);
+          case 2592e6: d.setDate(1);
+          case 6048e5: if (p == 6048e5) d.setDate(d.getDate() - d.getDay());
+          case 864e5: d.setHours(0);
+          case 36e5: d.setMinutes(0);
+          case 6e4: d.setSeconds(0);
+          case 1e3: d.setMilliseconds(0);
+        }
+      }
+
+      var precision, format, increment, step = 1;
+      if (span >= 3 * 31536e6) {
+        precision = 31536e6;
+        format = "%Y";
+        /** @ignore */ increment = function(d) { d.setFullYear(d.getFullYear() + step); };
+      } else if (span >= 3 * 2592e6) {
+        precision = 2592e6;
+        format = "%m/%Y";
+        /** @ignore */ increment = function(d) { d.setMonth(d.getMonth() + step); };
+      } else if (span >= 3 * 6048e5) {
+        precision = 6048e5;
+        format = "%m/%d";
+        /** @ignore */ increment = function(d) { d.setDate(d.getDate() + 7 * step); };
+      } else if (span >= 3 * 864e5) {
+        precision = 864e5;
+        format = "%m/%d";
+        /** @ignore */ increment = function(d) { d.setDate(d.getDate() + step); };
+      } else if (span >= 3 * 36e5) {
+        precision = 36e5;
+        format = "%I:%M %p";
+        /** @ignore */ increment = function(d) { d.setHours(d.getHours() + step); };
+      } else if (span >= 3 * 6e4) {
+        precision = 6e4;
+        format = "%I:%M %p";
+        /** @ignore */ increment = function(d) { d.setMinutes(d.getMinutes() + step); };
+      } else if (span >= 3 * 1e3) {
+        precision = 1e3;
+        format = "%I:%M:%S";
+        /** @ignore */ increment = function(d) { d.setSeconds(d.getSeconds() + step); };
+      } else {
+        precision = 1;
+        format = "%S.%Qs";
+        /** @ignore */ increment = function(d) { d.setTime(d.getTime() + step); };
+      }
+      tickFormat = pv.Format.date(format);
+
+      var date = new Date(min), dates = [];
+      floor(date, precision);
+
+      /* If we'd generate too many ticks, skip some!. */
+      var n = span / precision;
+      if (n > 10) {
+        switch (precision) {
+          case 36e5: {
+            step = (n > 20) ? 6 : 3;
+            date.setHours(Math.floor(date.getHours() / step) * step);
+            break;
+          }
+          case 2592e6: {
+            step = 3; // seasons
+            date.setMonth(Math.floor(date.getMonth() / step) * step);
+            break;
+          }
+          case 6e4: {
+            step = (n > 30) ? 15 : ((n > 15) ? 10 : 5);
+            date.setMinutes(Math.floor(date.getMinutes() / step) * step);
+            break;
+          }
+          case 1e3: {
+            step = (n > 90) ? 15 : ((n > 60) ? 10 : 5);
+            date.setSeconds(Math.floor(date.getSeconds() / step) * step);
+            break;
+          }
+          case 1: {
+            step = (n > 1000) ? 250 : ((n > 200) ? 100 : ((n > 100) ? 50 : ((n > 50) ? 25 : 5)));
+            date.setMilliseconds(Math.floor(date.getMilliseconds() / step) * step);
+            break;
+          }
+          default: {
+            step = pv.logCeil(n / 15, 10);
+            if (n / step < 2) step /= 5;
+            else if (n / step < 5) step /= 2;
+            date.setFullYear(Math.floor(date.getFullYear() / step) * step);
+            break;
+          }
+        }
+      }
+
+      while (true) {
+        increment(date);
+        if (date > max) break;
+        dates.push(new Date(date));
+      }
+      return reverse ? dates.reverse() : dates;
+    }
+
+    /* Normal case: numbers. */
+    if (!arguments.length) m = 10;
+    var step = pv.logFloor(span / m, 10),
+        err = m / (span / step);
+    if (err <= .15) step *= 10;
+    else if (err <= .35) step *= 5;
+    else if (err <= .75) step *= 2;
+    var start = Math.ceil(min / step) * step,
+        end = Math.floor(max / step) * step;
+    tickFormat = pv.Format.number()
+        .fractionDigits(Math.max(0, -Math.floor(pv.log(step, 10) + .01)));
+    var ticks = pv.range(start, end + step, step);
+    return reverse ? ticks.reverse() : ticks;
+  };
+
+  /**
+   * Formats the specified tick value using the appropriate precision, based on
+   * the step interval between tick marks. If {@link #ticks} has not been called,
+   * the argument is converted to a string, but no formatting is applied.
+   *
+   * @function
+   * @name pv.Scale.quantitative.prototype.tickFormat
+   * @param {number} t a tick value.
+   * @returns {string} a formatted tick value.
+   */
+  scale.tickFormat = function (t) { return tickFormat(t); };
+
+  /**
+   * "Nices" this scale, extending the bounds of the input domain to
+   * evenly-rounded values. Nicing is useful if the domain is computed
+   * dynamically from data, and may be irregular. For example, given a domain of
+   * [0.20147987687960267, 0.996679553296417], a call to <tt>nice()</tt> might
+   * extend the domain to [0.2, 1].
+   *
+   * <p>This method must be invoked each time after setting the domain.
+   *
+   * @function
+   * @name pv.Scale.quantitative.prototype.nice
+   * @returns {pv.Scale.quantitative} <tt>this</tt>.
+   */
+  scale.nice = function() {
+    if (d.length != 2) return this; // TODO support non-uniform domains
+    var start = d[0],
+        end = d[d.length - 1],
+        reverse = end < start,
+        min = reverse ? end : start,
+        max = reverse ? start : end,
+        span = max - min;
+
+    /* Special case: empty, invalid or infinite span. */
+    if (!span || !isFinite(span)) return this;
+
+    var step = Math.pow(10, Math.round(Math.log(span) / Math.log(10)) - 1);
+    d = [Math.floor(min / step) * step, Math.ceil(max / step) * step];
+    if (reverse) d.reverse();
+    l = d.map(f);
+    return this;
+  };
+
+  /**
+   * Returns a view of this scale by the specified accessor function <tt>f</tt>.
+   * Given a scale <tt>y</tt>, <tt>y.by(function(d) d.foo)</tt> is equivalent to
+   * <tt>function(d) y(d.foo)</tt>.
+   *
+   * <p>This method is provided for convenience, such that scales can be
+   * succinctly defined inline. For example, given an array of data elements
+   * that have a <tt>score</tt> attribute with the domain [0, 1], the height
+   * property could be specified as:
+   *
+   * <pre>    .height(pv.Scale.linear().range(0, 480).by(function(d) d.score))</pre>
+   *
+   * This is equivalent to:
+   *
+   * <pre>    .height(function(d) d.score * 480)</pre>
+   *
+   * This method should be used judiciously; it is typically more clear to
+   * invoke the scale directly, passing in the value to be scaled.
+   *
+   * @function
+   * @name pv.Scale.quantitative.prototype.by
+   * @param {function} f an accessor function.
+   * @returns {pv.Scale.quantitative} a view of this scale by the specified
+   * accessor function.
+   */
+  scale.by = function(f) {
+    function by() { return scale(f.apply(this, arguments)); }
+    for (var method in scale) by[method] = scale[method];
+    return by;
+  };
+
+  scale.domain.apply(scale, arguments);
+  return scale;
+};
diff --git a/vendor/protovis/src/data/RootScale.js b/vendor/protovis/src/data/RootScale.js
new file mode 100644
index 0000000..7dea8d6
--- /dev/null
+++ b/vendor/protovis/src/data/RootScale.js
@@ -0,0 +1,55 @@
+/**
+ * Returns a root scale for the specified domain. The arguments to this
+ * constructor are optional, and equivalent to calling {@link #domain}.
+ * The default domain and range are [0,1].
+ *
+ * @class Represents a root scale; a function that performs a power
+ * transformation. <style type="text/css">sub{line-height:0}</style> Most
+ * commonly, a root scale represents a 1-dimensional root transformation from a
+ * numeric domain of input data [<i>d<sub>0</sub></i>, <i>d<sub>1</sub></i>] to
+ * a numeric range of pixels [<i>r<sub>0</sub></i>, <i>r<sub>1</sub></i>].
+ *
+ * <p>Note that the scale is itself a function, and thus can be used as a
+ * property directly, assuming that the data associated with a mark is a
+ * number. While this is convenient for single-use scales, frequently it is
+ * desirable to define scales globally:
+ *
+ * <pre>var y = pv.Scale.root(0, 100).range(0, 640);</pre>
+ *
+ * The <tt>y</tt> scale can now be equivalently referenced within a property:
+ *
+ * <pre>    .height(function(d) y(d))</pre>
+ *
+ * Alternatively, if the data are not simple numbers, the appropriate value can
+ * be passed to the <tt>y</tt> scale (e.g., <tt>d.foo</tt>). The {@link #by}
+ * method similarly allows the data to be mapped to a numeric value before
+ * performing the root transformation.
+ *
+ * @param {number...} domain... optional domain values.
+ * @extends pv.Scale.quantitative
+ */
+pv.Scale.root = function() {
+  var scale = pv.Scale.quantitative();
+
+  /**
+   * Sets or gets the exponent; defaults to 2.
+   *
+   * @function
+   * @name pv.Scale.root.prototype.power
+   * @param {number} [v] the new exponent.
+   * @returns {pv.Scale.root} <tt>this</tt>, or the current base.
+   */
+  scale.power = function(v) {
+    if (arguments.length) {
+      var b = Number(v), p = 1 / b;
+      scale.transform(
+        function(x) { return Math.pow(x, p); },
+        function(y) { return Math.pow(y, b); });
+      return this;
+    }
+    return b;
+  };
+
+  scale.domain.apply(scale, arguments);
+  return scale.power(2);
+};
diff --git a/vendor/protovis/src/data/Scale.js b/vendor/protovis/src/data/Scale.js
new file mode 100644
index 0000000..13ca6eb
--- /dev/null
+++ b/vendor/protovis/src/data/Scale.js
@@ -0,0 +1,86 @@
+/**
+ * Abstract; see the various scale implementations.
+ *
+ * @class Represents a scale; a function that performs a transformation from
+ * data domain to visual range. For quantitative and quantile scales, the domain
+ * is expressed as numbers; for ordinal scales, the domain is expressed as
+ * strings (or equivalently objects with unique string representations). The
+ * "visual range" may correspond to pixel space, colors, font sizes, and the
+ * like.
+ *
+ * <p>Note that scales are functions, and thus can be used as properties
+ * directly, assuming that the data associated with a mark is a number. While
+ * this is convenient for single-use scales, frequently it is desirable to
+ * define scales globally:
+ *
+ * <pre>var y = pv.Scale.linear(0, 100).range(0, 640);</pre>
+ *
+ * The <tt>y</tt> scale can now be equivalently referenced within a property:
+ *
+ * <pre>    .height(function(d) y(d))</pre>
+ *
+ * Alternatively, if the data are not simple numbers, the appropriate value can
+ * be passed to the <tt>y</tt> scale (e.g., <tt>d.foo</tt>). The {@link #by}
+ * method similarly allows the data to be mapped to a numeric value before
+ * performing the linear transformation.
+ *
+ * @see pv.Scale.quantitative
+ * @see pv.Scale.quantile
+ * @see pv.Scale.ordinal
+ * @extends function
+ */
+pv.Scale = function() {};
+
+/**
+ * @private Returns a function that interpolators from the start value to the
+ * end value, given a parameter <i>t</i> in [0, 1].
+ *
+ * @param start the start value.
+ * @param end the end value.
+ */
+pv.Scale.interpolator = function(start, end) {
+  if (typeof start == "number") {
+    return function(t) {
+      return t * (end - start) + start;
+    };
+  }
+
+  /* For now, assume color. */
+  start = pv.color(start).rgb();
+  end = pv.color(end).rgb();
+  return function(t) {
+    var a = start.a * (1 - t) + end.a * t;
+    if (a < 1e-5) a = 0; // avoid scientific notation
+    return (start.a == 0) ? pv.rgb(end.r, end.g, end.b, a)
+        : ((end.a == 0) ? pv.rgb(start.r, start.g, start.b, a)
+        : pv.rgb(
+            Math.round(start.r * (1 - t) + end.r * t),
+            Math.round(start.g * (1 - t) + end.g * t),
+            Math.round(start.b * (1 - t) + end.b * t), a));
+  };
+};
+
+/**
+ * Returns a view of this scale by the specified accessor function <tt>f</tt>.
+ * Given a scale <tt>y</tt>, <tt>y.by(function(d) d.foo)</tt> is equivalent to
+ * <tt>function(d) y(d.foo)</tt>.
+ *
+ * <p>This method is provided for convenience, such that scales can be
+ * succinctly defined inline. For example, given an array of data elements that
+ * have a <tt>score</tt> attribute with the domain [0, 1], the height property
+ * could be specified as:
+ *
+ * <pre>    .height(pv.Scale.linear().range(0, 480).by(function(d) d.score))</pre>
+ *
+ * This is equivalent to:
+ *
+ * <pre>    .height(function(d) d.score * 480)</pre>
+ *
+ * This method should be used judiciously; it is typically more clear to invoke
+ * the scale directly, passing in the value to be scaled.
+ *
+ * @function
+ * @name pv.Scale.prototype.by
+ * @param {function} f an accessor function.
+ * @returns {pv.Scale} a view of this scale by the specified accessor function.
+ */
diff --git a/vendor/protovis/src/data/Transform.js b/vendor/protovis/src/data/Transform.js
new file mode 100644
index 0000000..4fc83d1
--- /dev/null
+++ b/vendor/protovis/src/data/Transform.js
@@ -0,0 +1,109 @@
+/**
+ * Returns a new identity transform.
+ *
+ * @class Represents a transformation matrix. The transformation matrix is
+ * limited to expressing translate and uniform scale transforms only; shearing,
+ * rotation, general affine, and other transforms are not supported.
+ *
+ * <p>The methods on this class treat the transform as immutable, returning a
+ * copy of the transformation matrix with the specified transform applied. Note,
+ * alternatively, that the matrix fields can be get and set directly.
+ */
+pv.Transform = function() {};
+pv.Transform.prototype = {k: 1, x: 0, y: 0};
+
+/**
+ * The scale magnitude; defaults to 1.
+ *
+ * @type number
+ * @name pv.Transform.prototype.k
+ */
+
+/**
+ * The x-offset; defaults to 0.
+ *
+ * @type number
+ * @name pv.Transform.prototype.x
+ */
+
+/**
+ * The y-offset; defaults to 0.
+ *
+ * @type number
+ * @name pv.Transform.prototype.y
+ */
+
+/**
+ * @private The identity transform.
+ *
+ * @type pv.Transform
+ */
+pv.Transform.identity = new pv.Transform();
+
+// k 0 x   1 0 a   k 0 ka+x
+// 0 k y * 0 1 b = 0 k kb+y
+// 0 0 1   0 0 1   0 0 1
+
+/**
+ * Returns a translated copy of this transformation matrix.
+ *
+ * @param {number} x the x-offset.
+ * @param {number} y the y-offset.
+ * @returns {pv.Transform} the translated transformation matrix.
+ */
+pv.Transform.prototype.translate = function(x, y) {
+  var v = new pv.Transform();
+  v.k = this.k;
+  v.x = this.k * x + this.x;
+  v.y = this.k * y + this.y;
+  return v;
+};
+
+// k 0 x   d 0 0   kd  0 x
+// 0 k y * 0 d 0 =  0 kd y
+// 0 0 1   0 0 1    0  0 1
+
+/**
+ * Returns a scaled copy of this transformation matrix.
+ *
+ * @param {number} k
+ * @returns {pv.Transform} the scaled transformation matrix.
+ */
+pv.Transform.prototype.scale = function(k) {
+  var v = new pv.Transform();
+  v.k = this.k * k;
+  v.x = this.x;
+  v.y = this.y;
+  return v;
+};
+
+/**
+ * Returns the inverse of this transformation matrix.
+ *
+ * @returns {pv.Transform} the inverted transformation matrix.
+ */
+pv.Transform.prototype.invert = function() {
+  var v = new pv.Transform(), k = 1 / this.k;
+  v.k = k;
+  v.x = -this.x * k;
+  v.y = -this.y * k;
+  return v;
+};
+
+// k 0 x   d 0 a   kd  0 ka+x
+// 0 k y * 0 d b =  0 kd kb+y
+// 0 0 1   0 0 1    0  0    1
+
+/**
+ * Returns this matrix post-multiplied by the specified matrix <i>m</i>.
+ *
+ * @param {pv.Transform} m
+ * @returns {pv.Transform} the post-multiplied transformation matrix.
+ */
+pv.Transform.prototype.times = function(m) {
+  var v = new pv.Transform();
+  v.k = this.k * m.k;
+  v.x = this.k * m.x + this.x;
+  v.y = this.k * m.y + this.y;
+  return v;
+};
diff --git a/vendor/protovis/src/data/Tree.js b/vendor/protovis/src/data/Tree.js
new file mode 100644
index 0000000..299b422
--- /dev/null
+++ b/vendor/protovis/src/data/Tree.js
@@ -0,0 +1,124 @@
+/**
+ * Returns a {@link pv.Tree} operator for the specified array. This is a
+ * convenience factory method, equivalent to <tt>new pv.Tree(array)</tt>.
+ *
+ * @see pv.Tree
+ * @param {array} array an array from which to construct a tree.
+ * @returns {pv.Tree} a tree operator for the specified array.
+ */
+pv.tree = function(array) {
+  return new pv.Tree(array);
+};
+
+/**
+ * Constructs a tree operator for the specified array. This constructor should
+ * not be invoked directly; use {@link pv.tree} instead.
+ *
+ * @class Represents a tree operator for the specified array. The tree operator
+ * allows a hierarchical map to be constructed from an array; it is similar to
+ * the {@link pv.Nest} operator, except the hierarchy is derived dynamically
+ * from the array elements.
+ *
+ * <p>For example, given an array of size information for ActionScript classes:
+ *
+ * <pre>{ name: "flare.flex.FlareVis", size: 4116 },
+ * { name: "flare.physics.DragForce", size: 1082 },
+ * { name: "flare.physics.GravityForce", size: 1336 }, ...</pre>
+ *
+ * To facilitate visualization, it may be useful to nest the elements by their
+ * package hierarchy:
+ *
+ * <pre>var tree = pv.tree(classes)
+ *     .keys(function(d) d.name.split("."))
+ *     .map();</pre>
+ *
+ * The resulting tree is:
+ *
+ * <pre>{ flare: {
+ *     flex: {
+ *       FlareVis: {
+ *         name: "flare.flex.FlareVis",
+ *         size: 4116 } },
+ *     physics: {
+ *       DragForce: {
+ *         name: "flare.physics.DragForce",
+ *         size: 1082 },
+ *       GravityForce: {
+ *         name: "flare.physics.GravityForce",
+ *         size: 1336 } },
+ *     ... } }</pre>
+ *
+ * By specifying a value function,
+ *
+ * <pre>var tree = pv.tree(classes)
+ *     .keys(function(d) d.name.split("."))
+ *     .value(function(d) d.size)
+ *     .map();</pre>
+ *
+ * we can further eliminate redundant data:
+ *
+ * <pre>{ flare: {
+ *     flex: {
+ *       FlareVis: 4116 },
+ *     physics: {
+ *       DragForce: 1082,
+ *       GravityForce: 1336 },
+ *   ... } }</pre>
+ *
+ * For visualizations with large data sets, performance improvements may be seen
+ * by storing the data in a tree format, and then flattening it into an array at
+ * runtime with {@link pv.Flatten}.
+ *
+ * @param {array} array an array from which to construct a tree.
+ */
+pv.Tree = function(array) {
+  this.array = array;
+};
+
+/**
+ * Assigns a <i>keys</i> function to this operator; required. The keys function
+ * returns an array of <tt>string</tt>s for each element in the associated
+ * array; these keys determine how the elements are nested in the tree. The
+ * returned keys should be unique for each element in the array; otherwise, the
+ * behavior of this operator is undefined.
+ *
+ * @param {function} k the keys function.
+ * @returns {pv.Tree} this.
+ */
+pv.Tree.prototype.keys = function(k) {
+  this.k = k;
+  return this;
+};
+
+/**
+ * Assigns a <i>value</i> function to this operator; optional. The value
+ * function specifies an optional transformation of the element in the array
+ * before it is inserted into the map. If no value function is specified, it is
+ * equivalent to using the identity function.
+ *
+ * @param {function} k the value function.
+ * @returns {pv.Tree} this.
+ */
+pv.Tree.prototype.value = function(v) {
+  this.v = v;
+  return this;
+};
+
+/**
+ * Returns a hierarchical map of values. The hierarchy is determined by the keys
+ * function; the values in the map are determined by the value function.
+ *
+ * @returns a hierarchical map of values.
+ */
+pv.Tree.prototype.map = function() {
+  var map = {}, o = {};
+  for (var i = 0; i < this.array.length; i++) {
+    o.index = i;
+    var value = this.array[i], keys = this.k.call(o, value), node = map;
+    for (var j = 0; j < keys.length - 1; j++) {
+      node = node[keys[j]] || (node[keys[j]] = {});
+    }
+    node[keys[j]] = this.v ? this.v.call(o, value) : value;
+  }
+  return map;
+};
diff --git a/vendor/protovis/src/data/Vector.js b/vendor/protovis/src/data/Vector.js
new file mode 100644
index 0000000..97cb9a0
--- /dev/null
+++ b/vendor/protovis/src/data/Vector.js
@@ -0,0 +1,118 @@
+/**
+ * Returns a {@link pv.Vector} for the specified <i>x</i> and <i>y</i>
+ * coordinate. This is a convenience factory method, equivalent to <tt>new
+ * pv.Vector(x, y)</tt>.
+ *
+ * @see pv.Vector
+ * @param {number} x the <i>x</i> coordinate.
+ * @param {number} y the <i>y</i> coordinate.
+ * @returns {pv.Vector} a vector for the specified coordinates.
+ */
+pv.vector = function(x, y) {
+  return new pv.Vector(x, y);
+};
+
+/**
+ * Constructs a {@link pv.Vector} for the specified <i>x</i> and <i>y</i>
+ * coordinate. This constructor should not be invoked directly; use
+ * {@link pv.vector} instead.
+ *
+ * @class Represents a two-dimensional vector; a 2-tuple <i>&#x27e8;x,
+ * y&#x27e9;</i>. The intent of this class is to simplify vector math. Note that
+ * in performance-sensitive cases it may be more efficient to represent 2D
+ * vectors as simple objects with <tt>x</tt> and <tt>y</tt> attributes, rather
+ * than using instances of this class.
+ *
+ * @param {number} x the <i>x</i> coordinate.
+ * @param {number} y the <i>y</i> coordinate.
+ */
+pv.Vector = function(x, y) {
+  this.x = x;
+  this.y = y;
+};
+
+/**
+ * Returns a vector perpendicular to this vector: <i>&#x27e8;-y, x&#x27e9;</i>.
+ *
+ * @returns {pv.Vector} a perpendicular vector.
+ */
+pv.Vector.prototype.perp = function() {
+  return new pv.Vector(-this.y, this.x);
+};
+
+/**
+ * Returns a normalized copy of this vector: a vector with the same direction,
+ * but unit length. If this vector has zero length this method returns a copy of
+ * this vector.
+ *
+ * @returns {pv.Vector} a unit vector.
+ */
+pv.Vector.prototype.norm = function() {
+  var l = this.length();
+  return this.times(l ? (1 / l) : 1);
+};
+
+/**
+ * Returns the magnitude of this vector, defined as <i>sqrt(x * x + y * y)</i>.
+ *
+ * @returns {number} a length.
+ */
+pv.Vector.prototype.length = function() {
+  return Math.sqrt(this.x * this.x + this.y * this.y);
+};
+
+/**
+ * Returns a scaled copy of this vector: <i>&#x27e8;x * k, y * k&#x27e9;</i>.
+ * To perform the equivalent divide operation, use <i>1 / k</i>.
+ *
+ * @param {number} k the scale factor.
+ * @returns {pv.Vector} a scaled vector.
+ */
+pv.Vector.prototype.times = function(k) {
+  return new pv.Vector(this.x * k, this.y * k);
+};
+
+/**
+ * Returns this vector plus the vector <i>v</i>: <i>&#x27e8;x + v.x, y +
+ * v.y&#x27e9;</i>. If only one argument is specified, it is interpreted as the
+ * vector <i>v</i>.
+ *
+ * @param {number} x the <i>x</i> coordinate to add.
+ * @param {number} y the <i>y</i> coordinate to add.
+ * @returns {pv.Vector} a new vector.
+ */
+pv.Vector.prototype.plus = function(x, y) {
+  return (arguments.length == 1)
+      ? new pv.Vector(this.x + x.x, this.y + x.y)
+      : new pv.Vector(this.x + x, this.y + y);
+};
+
+/**
+ * Returns this vector minus the vector <i>v</i>: <i>&#x27e8;x - v.x, y -
+ * v.y&#x27e9;</i>. If only one argument is specified, it is interpreted as the
+ * vector <i>v</i>.
+ *
+ * @param {number} x the <i>x</i> coordinate to subtract.
+ * @param {number} y the <i>y</i> coordinate to subtract.
+ * @returns {pv.Vector} a new vector.
+ */
+pv.Vector.prototype.minus = function(x, y) {
+  return (arguments.length == 1)
+      ? new pv.Vector(this.x - x.x, this.y - x.y)
+      : new pv.Vector(this.x - x, this.y - y);
+};
+
+/**
+ * Returns the dot product of this vector and the vector <i>v</i>: <i>x * v.x +
+ * y * v.y</i>. If only one argument is specified, it is interpreted as the
+ * vector <i>v</i>.
+ *
+ * @param {number} x the <i>x</i> coordinate to dot.
+ * @param {number} y the <i>y</i> coordinate to dot.
+ * @returns {number} a dot product.
+ */
+pv.Vector.prototype.dot = function(x, y) {
+  return (arguments.length == 1)
+      ? this.x * x.x + this.y * x.y
+      : this.x * x + this.y * y;
+};
diff --git a/vendor/protovis/src/geo/Geo.js b/vendor/protovis/src/geo/Geo.js
new file mode 100644
index 0000000..76abd2a
--- /dev/null
+++ b/vendor/protovis/src/geo/Geo.js
@@ -0,0 +1,5 @@
+/**
+ * @ignore
+ * @namespace
+ */
+pv.Geo = function() {};
diff --git a/vendor/protovis/src/geo/GeoScale.js b/vendor/protovis/src/geo/GeoScale.js
new file mode 100644
index 0000000..3e0a409
--- /dev/null
+++ b/vendor/protovis/src/geo/GeoScale.js
@@ -0,0 +1,307 @@
+/**
+ * Returns a geographic scale. The arguments to this constructor are optional,
+ * and equivalent to calling {@link #projection}.
+ *
+ * @class Represents a geographic scale; a mapping between latitude-longitude
+ * coordinates and screen pixel coordinates. By default, the domain is inferred
+ * from the geographic coordinates, so that the domain fills the output range.
+ *
+ * <p>Note that geographic scales are two-dimensional transformations, rather
+ * than the one-dimensional bidrectional mapping typical of other scales.
+ * Rather than mapping (for example) between a numeric domain and a numeric
+ * range, geographic scales map between two coordinate objects: {@link
+ * pv.Geo.LatLng} and {@link pv.Vector}.
+ *
+ * @param {pv.Geo.Projection} [p] optional projection.
+ * @see pv.Geo.scale#ticks
+ */
+pv.Geo.scale = function(p) {
+  var rmin = {x: 0, y: 0}, // default range minimum
+      rmax = {x: 1, y: 1}, // default range maximum
+      d = [], // default domain
+      j = pv.Geo.projections.identity, // domain <-> normalized range
+      x = pv.Scale.linear(-1, 1).range(0, 1), // normalized <-> range
+      y = pv.Scale.linear(-1, 1).range(1, 0), // normalized <-> range
+      c = {lng: 0, lat: 0}, // Center Point
+      lastLatLng, // cached latlng
+      lastPoint; // cached point
+
+  /** @private */
+  function scale(latlng) {
+    if (!lastLatLng
+        || (latlng.lng != lastLatLng.lng)
+        || (latlng.lat != lastLatLng.lat)) {
+      lastLatLng = latlng;
+      var p = project(latlng);
+      lastPoint = {x: x(p.x), y: y(p.y)};
+    }
+    return lastPoint;
+  }
+
+  /** @private */
+  function project(latlng) {
+    var offset = {lng: latlng.lng - c.lng, lat: latlng.lat};
+    return j.project(offset);
+  }
+
+  /** @private */
+  function invert(xy) {
+    var latlng = j.invert(xy);
+    latlng.lng += c.lng;
+    return latlng;
+  }
+
+  /** Returns the projected x-coordinate. */
+  scale.x = function(latlng) {
+    return scale(latlng).x;
+  };
+
+  /** Returns the projected y-coordinate. */
+  scale.y = function(latlng) {
+    return scale(latlng).y;
+  };
+
+  /**
+   * Abstract; this is a local namespace on a given geographic scale.
+   *
+   * @namespace Tick functions for geographic scales. Because geographic scales
+   * represent two-dimensional transformations (as opposed to one-dimensional
+   * transformations typical of other scales), the tick values are similarly
+   * represented as two-dimensional coordinates in the input domain, i.e.,
+   * {@link pv.Geo.LatLng} objects.
+   *
+   * <p>Also, note that non-rectilinear projections, such as sinsuoidal and
+   * aitoff, may not produce straight lines for constant longitude or constant
+   * latitude. Therefore the returned array of ticks is a two-dimensional array,
+   * sampling various latitudes as constant longitude, and vice versa.
+   *
+   * <p>The tick lines can therefore be approximated as polylines, either with
+   * "linear" or "cardinal" interpolation. This is not as accurate as drawing
+   * the true curve through the projection space, but is usually sufficient.
+   *
+   * @name pv.Geo.scale.prototype.ticks
+   * @see pv.Geo.scale
+   * @see pv.Geo.LatLng
+   * @see pv.Line#interpolate
+   */
+  scale.ticks = {
+
+    /**
+     * Returns longitude ticks.
+     *
+     * @function
+     * @param {number} [m] the desired number of ticks.
+     * @returns {array} a nested array of <tt>pv.Geo.LatLng</tt> ticks.
+     * @name pv.Geo.scale.prototype.ticks.prototype.lng
+     */
+    lng: function(m) {
+      var lat, lng;
+      if (d.length > 1) {
+        var s = pv.Scale.linear();
+        if (m == undefined) m = 10;
+        lat = s.domain(d, function(d) { return d.lat; }).ticks(m);
+        lng = s.domain(d, function(d) { return d.lng; }).ticks(m);
+      } else {
+        lat = pv.range(-80, 81, 10);
+        lng = pv.range(-180, 181, 10);
+      }
+      return lng.map(function(lng) {
+        return lat.map(function(lat) {
+          return {lat: lat, lng: lng};
+        });
+      });
+    },
+
+    /**
+     * Returns latitude ticks.
+     *
+     * @function
+     * @param {number} [m] the desired number of ticks.
+     * @returns {array} a nested array of <tt>pv.Geo.LatLng</tt> ticks.
+     * @name pv.Geo.scale.prototype.ticks.prototype.lat
+     */
+    lat: function(m) {
+      return pv.transpose(scale.ticks.lng(m));
+    }
+  };
+
+  /**
+   * Inverts the specified value in the output range, returning the
+   * corresponding value in the input domain. This is frequently used to convert
+   * the mouse location (see {@link pv.Mark#mouse}) to a value in the input
+   * domain. Inversion is only supported for numeric ranges, and not colors.
+   *
+   * <p>Note that this method does not do any rounding or bounds checking. If
+   * the input domain is discrete (e.g., an array index), the returned value
+   * should be rounded. If the specified <tt>y</tt> value is outside the range,
+   * the returned value may be equivalently outside the input domain.
+   *
+   * @function
+   * @name pv.Geo.scale.prototype.invert
+   * @param {number} y a value in the output range (a pixel location).
+   * @returns {number} a value in the input domain.
+   */
+  scale.invert = function(p) {
+    return invert({x: x.invert(p.x), y: y.invert(p.y)});
+  };
+
+  /**
+   * Sets or gets the input domain. Note that unlike quantitative scales, the
+   * domain cannot be reduced to a simple rectangle (i.e., minimum and maximum
+   * values for latitude and longitude). Instead, the domain values must be
+   * projected to normalized space, effectively finding the domain in normalized
+   * space rather than in terms of latitude and longitude. Thus, changing the
+   * projection requires recomputing the normalized domain.
+   *
+   * <p>This method can be invoked several ways:
+   *
+   * <p>1. <tt>domain(values...)</tt>
+   *
+   * <p>Specifying the domain as a series of {@link pv.Geo.LatLng}s is the most
+   * explicit and recommended approach. However, if the domain values are
+   * derived from data, you may find the second method more appropriate.
+   *
+   * <p>2. <tt>domain(array, f)</tt>
+   *
+   * <p>Rather than enumerating the domain explicitly, you can specify a single
+   * argument of an array. In addition, you can specify an optional accessor
+   * function to extract the domain values (as {@link pv.Geo.LatLng}s) from the
+   * array. If the specified array has fewer than two elements, this scale will
+   * default to the full normalized domain.
+   *
+   * <p>2. <tt>domain()</tt>
+   *
+   * <p>Invoking the <tt>domain</tt> method with no arguments returns the
+   * current domain as an array.
+   *
+   * @function
+   * @name pv.Geo.scale.prototype.domain
+   * @param {...} domain... domain values.
+   * @returns {pv.Geo.scale} <tt>this</tt>, or the current domain.
+   */
+  scale.domain = function(array, f) {
+    if (arguments.length) {
+      d = (array instanceof Array)
+          ? ((arguments.length > 1) ? pv.map(array, f) : array)
+          : Array.prototype.slice.call(arguments);
+      if (d.length > 1) {
+        var lngs = d.map(function(c) { return c.lng; });
+        var lats = d.map(function(c) { return c.lat; });
+        c = {
+          lng: (pv.max(lngs) + pv.min(lngs)) / 2,
+          lat: (pv.max(lats) + pv.min(lats)) / 2
+        };
+        var n = d.map(project); // normalized domain
+        x.domain(n, function(p) { return p.x; });
+        y.domain(n, function(p) { return p.y; });
+      } else {
+        c = {lng: 0, lat: 0};
+        x.domain(-1, 1);
+        y.domain(-1, 1);
+      }
+      lastLatLng = null; // invalidate the cache
+      return this;
+    }
+    return d;
+  };
+
+  /**
+   * Sets or gets the output range. This method can be invoked several ways:
+   *
+   * <p>1. <tt>range(min, max)</tt>
+   *
+   * <p>If two objects are specified, the arguments should be {@link pv.Vector}s
+   * which specify the minimum and maximum values of the x- and y-coordinates
+   * explicitly.
+   *
+   * <p>2. <tt>range(width, height)</tt>
+   *
+   * <p>If two numbers are specified, the arguments specify the maximum values
+   * of the x- and y-coordinates explicitly; the minimum values are implicitly
+   * zero.
+   *
+   * <p>3. <tt>range()</tt>
+   *
+   * <p>Invoking the <tt>range</tt> method with no arguments returns the current
+   * range as an array of two {@link pv.Vector}s: the minimum (top-left) and
+   * maximum (bottom-right) values.
+   *
+   * @function
+   * @name pv.Geo.scale.prototype.range
+   * @param {...} range... range values.
+   * @returns {pv.Geo.scale} <tt>this</tt>, or the current range.
+   */
+  scale.range = function(min, max) {
+    if (arguments.length) {
+      if (typeof min == "object") {
+        rmin = {x: Number(min.x), y: Number(min.y)};
+        rmax = {x: Number(max.x), y: Number(max.y)};
+      } else {
+        rmin = {x: 0, y: 0};
+        rmax = {x: Number(min), y: Number(max)};
+      }
+      x.range(rmin.x, rmax.x);
+      y.range(rmax.y, rmin.y); // XXX flipped?
+      lastLatLng = null; // invalidate the cache
+      return this;
+    }
+    return [rmin, rmax];
+  };
+
+  /**
+   * Sets or gets the projection. This method can be invoked several ways:
+   *
+   * <p>1. <tt>projection(string)</tt>
+   *
+   * <p>Specifying a string sets the projection to the given named projection in
+   * {@link pv.Geo.projections}. If no such projection is found, the identity
+   * projection is used.
+   *
+   * <p>2. <tt>projection(object)</tt>
+   *
+   * <p>Specifying an object sets the projection to the given custom projection,
+   * which must implement the <i>forward</i> and <i>inverse</i> methods per the
+   * {@link pv.Geo.Projection} interface.
+   *
+   * <p>3. <tt>projection()</tt>
+   *
+   * <p>Invoking the <tt>projection</tt> method with no arguments returns the
+   * current object that defined the projection.
+   *
+   * @function
+   * @name pv.Scale.geo.prototype.projection
+   * @param {...} range... range values.
+   * @returns {pv.Scale.geo} <tt>this</tt>, or the current range.
+   */
+  scale.projection = function(p) {
+    if (arguments.length) {
+      j = typeof p == "string"
+          ? pv.Geo.projections[p] || pv.Geo.projections.identity
+          : p;
+      return this.domain(d); // recompute normalized domain
+    }
+    return p;
+  };
+
+  /**
+   * Returns a view of this scale by the specified accessor function <tt>f</tt>.
+   * Given a scale <tt>g</tt>, <tt>g.by(function(d) d.foo)</tt> is equivalent to
+   * <tt>function(d) g(d.foo)</tt>. This method should be used judiciously; it
+   * is typically more clear to invoke the scale directly, passing in the value
+   * to be scaled.
+   *
+   * @function
+   * @name pv.Geo.scale.prototype.by
+   * @param {function} f an accessor function.
+   * @returns {pv.Geo.scale} a view of this scale by the specified accessor
+   * function.
+   */
+  scale.by = function(f) {
+    function by() { return scale(f.apply(this, arguments)); }
+    for (var method in scale) by[method] = scale[method];
+    return by;
+  };
+
+  if (arguments.length) scale.projection(p);
+  return scale;
+};
diff --git a/vendor/protovis/src/geo/LatLng.js b/vendor/protovis/src/geo/LatLng.js
new file mode 100644
index 0000000..722bcd1
--- /dev/null
+++ b/vendor/protovis/src/geo/LatLng.js
@@ -0,0 +1,23 @@
+/**
+ * Abstract; not implemented. There is no explicit constructor; this class
+ * merely serves to document the representation used by {@link pv.Geo.scale}.
+ *
+ * @class Represents a pair of geographic coordinates.
+ *
+ * @name pv.Geo.LatLng
+ * @see pv.Geo.scale
+ */
+
+/**
+ * The <i>latitude</i> coordinate in degrees; positive is North.
+ *
+ * @type number
+ * @name pv.Geo.LatLng.prototype.lat
+ */
+
+/**
+ * The <i>longitude</i> coordinate in degrees; positive is East.
+ *
+ * @type number
+ * @name pv.Geo.LatLng.prototype.lng
+ */
diff --git a/vendor/protovis/src/geo/Projection.js b/vendor/protovis/src/geo/Projection.js
new file mode 100644
index 0000000..8d94d46
--- /dev/null
+++ b/vendor/protovis/src/geo/Projection.js
@@ -0,0 +1,43 @@
+/**
+ * Abstract; not implemented. There is no explicit constructor; this class
+ * merely serves to document the representation used by {@link pv.Geo.scale}.
+ *
+ * @class Represents a geographic projection. This class provides the core
+ * implementation for {@link pv.Geo.scale}s, mapping between geographic
+ * coordinates (latitude and longitude) and normalized screen space in the range
+ * [-1,1]. The remaining mapping between normalized screen space and actual
+ * pixels is performed by <tt>pv.Geo.scale</tt>.
+ *
+ * <p>Many geographic projections have a point around which the projection is
+ * centered. Rather than have each implementation add support for a
+ * user-specified center point, the <tt>pv.Geo.scale</tt> translates the
+ * geographic coordinates relative to the center point for both the forward and
+ * inverse projection.
+ *
+ * <p>In general, this class should not be used directly, unless the desire is
+ * to implement a new geographic projection. Instead, use <tt>pv.Geo.scale</tt>.
+ * Implementations are not required to implement inverse projections, but are
+ * needed for some forms of interactivity. Also note that some inverse
+ * projections are ambiguous, such as the connecting points in Dymaxian maps.
+ *
+ * @name pv.Geo.Projection
+ * @see pv.Geo.scale
+ */
+
+/**
+ * The <i>forward</i> projection.
+ *
+ * @function
+ * @name pv.Geo.Projection.prototype.project
+ * @param {pv.Geo.LatLng} latlng the latitude and longitude to project.
+ * @returns {pv.Vector} the xy-coordinates of the given point.
+ */
+
+/**
+ * The <i>inverse</i> projection; optional.
+ *
+ * @function
+ * @name pv.Geo.Projection.prototype.invert
+ * @param {pv.Vector} xy the x- and y-coordinates to invert.
+ * @returns {pv.Geo.LatLng} the latitude and longitude of the given point.
+ */
diff --git a/vendor/protovis/src/geo/Projections.js b/vendor/protovis/src/geo/Projections.js
new file mode 100644
index 0000000..4580ca3
--- /dev/null
+++ b/vendor/protovis/src/geo/Projections.js
@@ -0,0 +1,117 @@
+/**
+ * The built-in projections.
+ *
+ * @see pv.Geo.Projection
+ * @namespace
+ */
+pv.Geo.projections = {
+
+  /** @see http://en.wikipedia.org/wiki/Mercator_projection */
+  mercator: {
+    project: function(latlng) {
+      return {
+          x: latlng.lng / 180,
+          y: latlng.lat > 85 ? 1 : latlng.lat < -85 ? -1
+              : Math.log(Math.tan(Math.PI / 4
+              + pv.radians(latlng.lat) / 2)) / Math.PI
+        };
+    },
+    invert: function(xy) {
+      return {
+          lng: xy.x * 180,
+          lat: pv.degrees(2 * Math.atan(Math.exp(xy.y * Math.PI)) - Math.PI / 2)
+        };
+    }
+  },
+
+  /** @see http://en.wikipedia.org/wiki/Gall-Peters_projection */
+  "gall-peters": {
+    project: function(latlng) {
+      return {
+          x: latlng.lng / 180,
+          y: Math.sin(pv.radians(latlng.lat))
+        };
+    },
+    invert: function(xy) {
+      return {
+          lng: xy.x * 180,
+          lat: pv.degrees(Math.asin(xy.y))
+        };
+    }
+  },
+
+  /** @see http://en.wikipedia.org/wiki/Sinusoidal_projection */
+  sinusoidal: {
+    project: function(latlng) {
+      return {
+          x: pv.radians(latlng.lng) * Math.cos(pv.radians(latlng.lat)) / Math.PI,
+          y: latlng.lat / 90
+        };
+    },
+    invert: function(xy) {
+      return {
+          lng: pv.degrees((xy.x * Math.PI) / Math.cos(xy.y * Math.PI / 2)),
+          lat: xy.y * 90
+        };
+    }
+  },
+
+  /** @see http://en.wikipedia.org/wiki/Aitoff_projection */
+  aitoff: {
+    project: function(latlng) {
+      var l = pv.radians(latlng.lng),
+          f = pv.radians(latlng.lat),
+          a = Math.acos(Math.cos(f) * Math.cos(l / 2));
+      return {
+          x: 2 * (a ? (Math.cos(f) * Math.sin(l / 2) * a / Math.sin(a)) : 0) / Math.PI,
+          y: 2 * (a ? (Math.sin(f) * a / Math.sin(a)) : 0) / Math.PI
+        };
+    },
+    invert: function(xy) {
+      var x = xy.x * Math.PI / 2,
+          y = xy.y * Math.PI / 2;
+      return {
+          lng: pv.degrees(x / Math.cos(y)),
+          lat: pv.degrees(y)
+        };
+    }
+  },
+
+  /** @see http://en.wikipedia.org/wiki/Hammer_projection */
+  hammer: {
+    project: function(latlng) {
+      var l = pv.radians(latlng.lng),
+          f = pv.radians(latlng.lat),
+          c = Math.sqrt(1 + Math.cos(f) * Math.cos(l / 2));
+      return {
+          x: 2 * Math.SQRT2 * Math.cos(f) * Math.sin(l / 2) / c / 3,
+          y: Math.SQRT2 * Math.sin(f) / c / 1.5
+        };
+    },
+    invert: function(xy) {
+      var x = xy.x * 3,
+          y = xy.y * 1.5,
+          z = Math.sqrt(1 - x * x / 16 - y * y / 4);
+      return {
+          lng: pv.degrees(2 * Math.atan2(z * x, 2 * (2 * z * z - 1))),
+          lat: pv.degrees(Math.asin(z * y))
+        };
+    }
+  },
+
+  /** The identity or "none" projection. */
+  identity: {
+    project: function(latlng) {
+      return {
+          x: latlng.lng / 180,
+          y: latlng.lat / 90
+        };
+    },
+    invert: function(xy) {
+      return {
+          lng: xy.x * 180,
+          lat: xy.y * 90
+        };
+    }
+  }
+};
diff --git a/vendor/protovis/src/lang/Array.js b/vendor/protovis/src/lang/Array.js
new file mode 100644
index 0000000..fcbd83f
--- /dev/null
+++ b/vendor/protovis/src/lang/Array.js
@@ -0,0 +1,112 @@
+/**
+ * @class The built-in Array class.
+ * @name Array
+ */
+
+/**
+ * Creates a new array with the results of calling a provided function on every
+ * element in this array. Implemented in Javascript 1.6.
+ *
+ * @function
+ * @name Array.prototype.map
+ * @see <a
+ * href="https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Objects/Array/Map">map</a>
+ * documentation.
+ * @param {function} f function that produces an element of the new Array from
+ * an element of the current one.
+ * @param [o] object to use as <tt>this</tt> when executing <tt>f</tt>.
+ */
+if (!Array.prototype.map) Array.prototype.map = function(f, o) {
+  var n = this.length;
+  var result = new Array(n);
+  for (var i = 0; i < n; i++) {
+    if (i in this) {
+      result[i] = f.call(o, this[i], i, this);
+    }
+  }
+  return result;
+};
+
+/**
+ * Creates a new array with all elements that pass the test implemented by the
+ * provided function. Implemented in Javascript 1.6.
+ *
+ * @function
+ * @name Array.prototype.filter
+ * @see <a
+ * href="https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Objects/Array/filter">filter</a>
+ * documentation.
+ * @param {function} f function to test each element of the array.
+ * @param [o] object to use as <tt>this</tt> when executing <tt>f</tt>.
+ */
+if (!Array.prototype.filter) Array.prototype.filter = function(f, o) {
+  var n = this.length;
+  var result = new Array();
+  for (var i = 0; i < n; i++) {
+    if (i in this) {
+      var v = this[i];
+      if (f.call(o, v, i, this)) result.push(v);
+    }
+  }
+  return result;
+};
+
+/**
+ * Executes a provided function once per array element. Implemented in
+ * Javascript 1.6.
+ *
+ * @function
+ * @name Array.prototype.forEach
+ * @see <a
+ * href="https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Objects/Array/ForEach">forEach</a>
+ * documentation.
+ * @param {function} f function to execute for each element.
+ * @param [o] object to use as <tt>this</tt> when executing <tt>f</tt>.
+ */
+if (!Array.prototype.forEach) Array.prototype.forEach = function(f, o) {
+  var n = this.length >>> 0;
+  for (var i = 0; i < n; i++) {
+    if (i in this) f.call(o, this[i], i, this);
+  }
+};
+
+/**
+ * Apply a function against an accumulator and each value of the array (from
+ * left-to-right) as to reduce it to a single value. Implemented in Javascript
+ * 1.8.
+ *
+ * @function
+ * @name Array.prototype.reduce
+ * @see <a
+ * href="https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Objects/Array/Reduce">reduce</a>
+ * documentation.
+ * @param {function} f function to execute on each value in the array.
+ * @param [v] object to use as the first argument to the first call of
+ * <tt>t</tt>.
+ */
+if (!Array.prototype.reduce) Array.prototype.reduce = function(f, v) {
+  var len = this.length;
+  if (!len && (arguments.length == 1)) {
+    throw new Error("reduce: empty array, no initial value");
+  }
+
+  var i = 0;
+  if (arguments.length < 2) {
+    while (true) {
+      if (i in this) {
+        v = this[i++];
+        break;
+      }
+      if (++i >= len) {
+        throw new Error("reduce: no values, no initial value");
+      }
+    }
+  }
+
+  for (; i < len; i++) {
+    if (i in this) {
+      v = f(v, this[i], i, this);
+    }
+  }
+  return v;
+};
diff --git a/vendor/protovis/src/lang/init.js b/vendor/protovis/src/lang/init.js
new file mode 100644
index 0000000..1b54172
--- /dev/null
+++ b/vendor/protovis/src/lang/init.js
@@ -0,0 +1,26 @@
+/*
+ * Parses the Protovis specifications on load, allowing the use of JavaScript
+ * 1.8 function expressions on browsers that only support JavaScript 1.6.
+ *
+ * @see pv.parse
+ */
+pv.listen(window, "load", function() {
+   /*
+    * Note: in Firefox any variables declared here are visible to the eval'd
+    * script below. Even worse, any global variables declared by the script
+    * could overwrite local variables here (such as the index, `i`)!  To protect
+    * against this, all variables are explicitly scoped on a pv.$ object.
+    */
+    pv.$ = {i:0, x:document.getElementsByTagName("script")};
+    for (; pv.$.i < pv.$.x.length; pv.$.i++) {
+      pv.$.s = pv.$.x[pv.$.i];
+      if (pv.$.s.type == "text/javascript+protovis") {
+        try {
+          window.eval(pv.parse(pv.$.s.text));
+        } catch (e) {
+          pv.error(e);
+        }
+      }
+    }
+    delete pv.$;
+  });
diff --git a/vendor/protovis/src/layout/Arc.js b/vendor/protovis/src/layout/Arc.js
new file mode 100644
index 0000000..92a157e
--- /dev/null
+++ b/vendor/protovis/src/layout/Arc.js
@@ -0,0 +1,178 @@
+/**
+ * Constructs a new, empty arc layout. Layouts are not typically constructed
+ * directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class Implements a layout for arc diagrams. An arc diagram is a network
+ * visualization with a one-dimensional layout of nodes, using circular arcs to
+ * render links between nodes. For undirected networks, arcs are rendering on a
+ * single side; this makes arc diagrams useful as annotations to other
+ * two-dimensional network layouts, such as rollup, matrix or table layouts. For
+ * directed networks, links in opposite directions can be rendered on opposite
+ * sides using <tt>directed(true)</tt>.
+ *
+ * <p>Arc layouts are particularly sensitive to node ordering; for best results,
+ * order the nodes such that related nodes are close to each other. A poor
+ * (e.g., random) order may result in large arcs with crossovers that impede
+ * visual processing. A future improvement to this layout may include automatic
+ * reordering using, e.g., spectral graph layout or simulated annealing.
+ *
+ * <p>This visualization technique is related to that developed by
+ * M. Wattenberg, <a
+ * href="http://www.research.ibm.com/visual/papers/arc-diagrams.pdf">"Arc
+ * Diagrams: Visualizing Structure in Strings"</a> in <i>IEEE InfoVis</i>, 2002.
+ * However, this implementation is limited to simple node-link networks, as
+ * opposed to structures with hierarchical self-similarity (such as strings).
+ *
+ * <p>As with other network layouts, three mark prototypes are provided:<ul>
+ *
+ * <li><tt>node</tt> - for rendering nodes; typically a {@link pv.Dot}.
+ * <li><tt>link</tt> - for rendering links; typically a {@link pv.Line}.
+ * <li><tt>label</tt> - for rendering node labels; typically a {@link pv.Label}.
+ *
+ * </ul>For more details on how this layout is structured and can be customized,
+ * see {@link pv.Layout.Network}.
+ *
+ * @extends pv.Layout.Network
+ **/
+pv.Layout.Arc = function() {
+  pv.Layout.Network.call(this);
+  var interpolate, // cached interpolate
+      directed, // cached directed
+      reverse, // cached reverse
+      buildImplied = this.buildImplied;
+
+  /** @private Cache layout state to optimize properties. */
+  this.buildImplied = function(s) {
+    buildImplied.call(this, s);
+    directed = s.directed;
+    interpolate = s.orient == "radial" ? "linear" : "polar";
+    reverse = s.orient == "right" || s.orient == "top";
+  };
+
+  /* Override link properties to handle directedness and orientation. */
+  this.link
+      .data(function(p) {
+          var s = p.sourceNode, t = p.targetNode;
+          return reverse != (directed || (s.breadth < t.breadth)) ? [s, t] : [t, s];
+        })
+      .interpolate(function() { return interpolate; });
+};
+
+pv.Layout.Arc.prototype = pv.extend(pv.Layout.Network)
+    .property("orient", String)
+    .property("directed", Boolean);
+
+/**
+ * Default properties for arc layouts. By default, the orientation is "bottom".
+ *
+ * @type pv.Layout.Arc
+ */
+pv.Layout.Arc.prototype.defaults = new pv.Layout.Arc()
+    .extend(pv.Layout.Network.prototype.defaults)
+    .orient("bottom");
+
+/**
+ * Specifies an optional sort function. The sort function follows the same
+ * comparator contract required by {@link pv.Dom.Node#sort}. Specifying a sort
+ * function provides an alternative to sort the nodes as they are specified by
+ * the <tt>nodes</tt> property; the main advantage of doing this is that the
+ * comparator function can access implicit fields populated by the network
+ * layout, such as the <tt>linkDegree</tt>.
+ *
+ * <p>Note that arc diagrams are particularly sensitive to order. This is
+ * referred to as the seriation problem, and many different techniques exist to
+ * find good node orders that emphasize clusters, such as spectral layout and
+ * simulated annealing.
+ *
+ * @param {function} f comparator function for nodes.
+ * @returns {pv.Layout.Arc} this.
+ */
+pv.Layout.Arc.prototype.sort = function(f) {
+  this.$sort = f;
+  return this;
+};
+
+/** @private Populates the x, y and angle attributes on the nodes. */
+pv.Layout.Arc.prototype.buildImplied = function(s) {
+  if (pv.Layout.Network.prototype.buildImplied.call(this, s)) return;
+
+  var nodes = s.nodes,
+      orient = s.orient,
+      sort = this.$sort,
+      index = pv.range(nodes.length),
+      w = s.width,
+      h = s.height,
+      r = Math.min(w, h) / 2;
+
+  /* Sort the nodes. */
+  if (sort) index.sort(function(a, b) { return sort(nodes[a], nodes[b]); });
+
+  /** @private Returns the mid-angle, given the breadth. */
+  function midAngle(b) {
+    switch (orient) {
+      case "top": return -Math.PI / 2;
+      case "bottom": return Math.PI / 2;
+      case "left": return Math.PI;
+      case "right": return 0;
+      case "radial": return (b - .25) * 2 * Math.PI;
+    }
+  }
+
+  /** @private Returns the x-position, given the breadth. */
+  function x(b) {
+    switch (orient) {
+      case "top":
+      case "bottom": return b * w;
+      case "left": return 0;
+      case "right": return w;
+      case "radial": return w / 2 + r * Math.cos(midAngle(b));
+    }
+  }
+
+  /** @private Returns the y-position, given the breadth. */
+  function y(b) {
+    switch (orient) {
+      case "top": return 0;
+      case "bottom": return h;
+      case "left":
+      case "right": return b * h;
+      case "radial": return h / 2 + r * Math.sin(midAngle(b));
+    }
+  }
+
+  /* Populate the x, y and mid-angle attributes. */
+  for (var i = 0; i < nodes.length; i++) {
+    var n = nodes[index[i]], b = n.breadth = (i + .5) / nodes.length;
+    n.x = x(b);
+    n.y = y(b);
+    n.midAngle = midAngle(b);
+  }
+};
+
+/**
+ * The orientation. The default orientation is "left", which means that nodes
+ * will be positioned from left-to-right in the order they are specified in the
+ * <tt>nodes</tt> property. The following orientations are supported:<ul>
+ *
+ * <li>left - left-to-right.
+ * <li>right - right-to-left.
+ * <li>top - top-to-bottom.
+ * <li>bottom - bottom-to-top.
+ * <li>radial - radially, starting at 12 o'clock and proceeding clockwise.</ul>
+ *
+ * @type string
+ * @name pv.Layout.Arc.prototype.orient
+ */
+
+/**
+ * Whether this arc digram is directed (bidirectional); only applies to
+ * non-radial orientations. By default, arc digrams are undirected, such that
+ * all arcs appear on one side. If the arc digram is directed, then forward
+ * links are drawn on the conventional side (the same as as undirected
+ * links--right, left, bottom and top for left, right, top and bottom,
+ * respectively), while reverse links are drawn on the opposite side.
+ *
+ * @type boolean
+ * @name pv.Layout.Arc.prototype.directed
+ */
diff --git a/vendor/protovis/src/layout/Bullet.js b/vendor/protovis/src/layout/Bullet.js
new file mode 100644
index 0000000..6dee0fb
--- /dev/null
+++ b/vendor/protovis/src/layout/Bullet.js
@@ -0,0 +1,164 @@
+// ranges (bad, satisfactory, good)
+// measures (actual, forecast)
+// markers (previous, goal)
+
+/*
+ * Chart design based on the recommendations of Stephen Few. Implementation
+ * based on the work of Clint Ivy, Jamie Love, and Jason Davies.
+ * http://projects.instantcognition.com/protovis/bulletchart/
+ */
+
+/**
+ * Constructs a new, empty bullet layout. Layouts are not typically constructed
+ * directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class
+ * @extends pv.Layout
+ */
+pv.Layout.Bullet = function() {
+  pv.Layout.call(this);
+  var that = this,
+      buildImplied = that.buildImplied,
+      scale = that.x = pv.Scale.linear(),
+      orient,
+      horizontal,
+      rangeColor,
+      measureColor,
+      x;
+
+  /** @private Cache layout state to optimize properties. */
+  this.buildImplied = function(s) {
+    buildImplied.call(this, x = s);
+    orient = s.orient;
+    horizontal = /^left|right$/.test(orient);
+    rangeColor = pv.ramp("#bbb", "#eee")
+        .domain(0, Math.max(1, x.ranges.length - 1));
+    measureColor = pv.ramp("steelblue", "lightsteelblue")
+        .domain(0, Math.max(1, x.measures.length - 1));
+  };
+
+  /**
+   * The range prototype.
+   *
+   * @type pv.Mark
+   * @name pv.Layout.Bullet.prototype.range
+   */
+  (this.range = new pv.Mark())
+      .data(function() { return x.ranges; })
+      .reverse(true)
+      .left(function() { return orient == "left" ? 0 : null; })
+      .top(function() { return orient == "top" ? 0 : null; })
+      .right(function() { return orient == "right" ? 0 : null; })
+      .bottom(function() { return orient == "bottom" ? 0 : null; })
+      .width(function(d) { return horizontal ? scale(d) : null; })
+      .height(function(d) { return horizontal ? null : scale(d); })
+      .fillStyle(function() { return rangeColor(this.index); })
+      .antialias(false)
+      .parent = that;
+
+  /**
+   * The measure prototype.
+   *
+   * @type pv.Mark
+   * @name pv.Layout.Bullet.prototype.measure
+   */
+  (this.measure = new pv.Mark())
+      .extend(this.range)
+      .data(function() { return x.measures; })
+      .left(function() { return orient == "left" ? 0 : horizontal ? null : this.parent.width() / 3.25; })
+      .top(function() { return orient == "top" ? 0 : horizontal ? this.parent.height() / 3.25 : null; })
+      .right(function() { return orient == "right" ? 0 : horizontal ? null : this.parent.width() / 3.25; })
+      .bottom(function() { return orient == "bottom" ? 0 : horizontal ? this.parent.height() / 3.25 : null; })
+      .fillStyle(function() { return measureColor(this.index); })
+      .parent = that;
+
+  /**
+   * The marker prototype.
+   *
+   * @type pv.Mark
+   * @name pv.Layout.Bullet.prototype.marker
+   */
+  (this.marker = new pv.Mark())
+      .data(function() { return x.markers; })
+      .left(function(d) { return orient == "left" ? scale(d) : horizontal ? null : this.parent.width() / 2; })
+      .top(function(d) { return orient == "top" ? scale(d) : horizontal ? this.parent.height() / 2 : null; })
+      .right(function(d) { return orient == "right" ? scale(d) : null; })
+      .bottom(function(d) { return orient == "bottom" ? scale(d) : null; })
+      .strokeStyle("black")
+      .shape("bar")
+      .shapeAngle(function() { return horizontal ? 0 : Math.PI / 2; })
+      .parent = that;
+
+  (this.tick = new pv.Mark())
+      .data(function() { return scale.ticks(7); })
+      .left(function(d) { return orient == "left" ? scale(d) : null; })
+      .top(function(d) { return orient == "top" ? scale(d) : null; })
+      .right(function(d) { return orient == "right" ? scale(d) : horizontal ? null : -6; })
+      .bottom(function(d) { return orient == "bottom" ? scale(d) : horizontal ? -8 : null; })
+      .height(function() { return horizontal ? 6 : null; })
+      .width(function() { return horizontal ? null : 6; })
+      .parent = that;
+};
+
+pv.Layout.Bullet.prototype = pv.extend(pv.Layout)
+    .property("orient", String) // left, right, top, bottom
+    .property("ranges")
+    .property("markers")
+    .property("measures")
+    .property("maximum", Number);
+
+/**
+ * Default properties for bullet layouts.
+ *
+ * @type pv.Layout.Bullet
+ */
+pv.Layout.Bullet.prototype.defaults = new pv.Layout.Bullet()
+    .extend(pv.Layout.prototype.defaults)
+    .orient("left")
+    .ranges([])
+    .markers([])
+    .measures([]);
+
+/**
+ * The orientation.
+ *
+ * @type string
+ * @name pv.Layout.Bullet.prototype.orient
+ */
+
+/**
+ * The array of range values.
+ *
+ * @type array
+ * @name pv.Layout.Bullet.prototype.ranges
+ */
+
+/**
+ * The array of marker values.
+ *
+ * @type array
+ * @name pv.Layout.Bullet.prototype.markers
+ */
+
+/**
+ * The array of measure values.
+ *
+ * @type array
+ * @name pv.Layout.Bullet.prototype.measures
+ */
+
+/**
+ * Optional; the maximum range value.
+ *
+ * @type number
+ * @name pv.Layout.Bullet.prototype.maximum
+ */
+
+/** @private */
+pv.Layout.Bullet.prototype.buildImplied = function(s) {
+  pv.Layout.prototype.buildImplied.call(this, s);
+  var size = this.parent[/^left|right$/.test(s.orient) ? "width" : "height"]();
+  s.maximum = s.maximum || pv.max([].concat(s.ranges, s.markers, s.measures));
+  this.x.domain(0, s.maximum).range(0, size);
+};
diff --git a/vendor/protovis/src/layout/Cluster.js b/vendor/protovis/src/layout/Cluster.js
new file mode 100644
index 0000000..4183489
--- /dev/null
+++ b/vendor/protovis/src/layout/Cluster.js
@@ -0,0 +1,205 @@
+/**
+ * Constructs a new, empty cluster layout. Layouts are not typically
+ * constructed directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class Implements a hierarchical layout using the cluster (or dendrogram)
+ * algorithm. This layout provides both node-link and space-filling
+ * implementations of cluster diagrams. In many ways it is similar to
+ * {@link pv.Layout.Partition}, except that leaf nodes are positioned at maximum
+ * depth, and the depth of internal nodes is based on their distance from their
+ * deepest descendant, rather than their distance from the root.
+ *
+ * <p>The cluster layout supports a "group" property, which if true causes
+ * siblings to be positioned closer together than unrelated nodes at the same
+ * depth. Unlike the partition layout, this layout does not support dynamic
+ * sizing for leaf nodes; all leaf nodes are the same size.
+ *
+ * <p>For more details on how to use this layout, see
+ * {@link pv.Layout.Hierarchy}.
+ *
+ * @see pv.Layout.Cluster.Fill
+ * @extends pv.Layout.Hierarchy
+ */
+pv.Layout.Cluster = function() {
+  pv.Layout.Hierarchy.call(this);
+  var interpolate, // cached interpolate
+      buildImplied = this.buildImplied;
+
+  /** @private Cache layout state to optimize properties. */
+  this.buildImplied = function(s) {
+    buildImplied.call(this, s);
+    interpolate
+        = /^(top|bottom)$/.test(s.orient) ? "step-before"
+        : /^(left|right)$/.test(s.orient) ? "step-after"
+        : "linear";
+  };
+
+  this.link.interpolate(function() { return interpolate; });
+};
+
+pv.Layout.Cluster.prototype = pv.extend(pv.Layout.Hierarchy)
+    .property("group", Number)
+    .property("orient", String)
+    .property("innerRadius", Number)
+    .property("outerRadius", Number);
+
+/**
+ * The group parameter; defaults to 0, disabling grouping of siblings. If this
+ * parameter is set to a positive number (or true, which is equivalent to 1),
+ * then additional space will be allotted between sibling groups. In other
+ * words, siblings (nodes that share the same parent) will be positioned more
+ * closely than nodes at the same depth that do not share a parent.
+ *
+ * @type number
+ * @name pv.Layout.Cluster.prototype.group
+ */
+
+/**
+ * The orientation. The default orientation is "top", which means that the root
+ * node is placed on the top edge, leaf nodes appear on the bottom edge, and
+ * internal nodes are in-between. The following orientations are supported:<ul>
+ *
+ * <li>left - left-to-right.
+ * <li>right - right-to-left.
+ * <li>top - top-to-bottom.
+ * <li>bottom - bottom-to-top.
+ * <li>radial - radially, with the root at the center.</ul>
+ *
+ * @type string
+ * @name pv.Layout.Cluster.prototype.orient
+ */
+
+/**
+ * The inner radius; defaults to 0. This property applies only to radial
+ * orientations, and can be used to compress the layout radially. Note that for
+ * the node-link implementation, the root node is always at the center,
+ * regardless of the value of this property; this property only affects internal
+ * and leaf nodes. For the space-filling implementation, a non-zero value of
+ * this property will result in the root node represented as a ring rather than
+ * a circle.
+ *
+ * @type number
+ * @name pv.Layout.Cluster.prototype.innerRadius
+ */
+
+/**
+ * The outer radius; defaults to fill the containing panel, based on the height
+ * and width of the layout. If the layout has no height and width specified, it
+ * will extend to fill the enclosing panel.
+ *
+ * @type number
+ * @name pv.Layout.Cluster.prototype.outerRadius
+ */
+
+/**
+ * Defaults for cluster layouts. The default group parameter is 0 and the
+ * default orientation is "top".
+ *
+ * @type pv.Layout.Cluster
+ */
+pv.Layout.Cluster.prototype.defaults = new pv.Layout.Cluster()
+    .extend(pv.Layout.Hierarchy.prototype.defaults)
+    .group(0)
+    .orient("top");
+
+/** @private */
+pv.Layout.Cluster.prototype.buildImplied = function(s) {
+  if (pv.Layout.Hierarchy.prototype.buildImplied.call(this, s)) return;
+
+  var root = s.nodes[0],
+      group = s.group,
+      breadth,
+      depth,
+      leafCount = 0,
+      leafIndex = .5 - group / 2;
+
+  /* Count the leaf nodes and compute the depth of descendants. */
+  var p = undefined;
+  root.visitAfter(function(n) {
+      if (n.firstChild) {
+        n.depth = 1 + pv.max(n.childNodes, function(n) { return n.depth; });
+      } else {
+        if (group && (p != n.parentNode)) {
+          p = n.parentNode;
+          leafCount += group;
+        }
+        leafCount++;
+        n.depth = 0;
+      }
+    });
+  breadth = 1 / leafCount;
+  depth = 1 / root.depth;
+
+  /* Compute the unit breadth and depth of each node. */
+  var p = undefined;
+  root.visitAfter(function(n) {
+      if (n.firstChild) {
+        n.breadth = pv.mean(n.childNodes, function(n) { return n.breadth; });
+      } else {
+        if (group && (p != n.parentNode)) {
+          p = n.parentNode;
+          leafIndex += group;
+        }
+        n.breadth = breadth * leafIndex++;
+      }
+      n.depth = 1 - n.depth * depth;
+    });
+
+  /* Compute breadth and depth ranges for space-filling layouts. */
+  root.visitAfter(function(n) {
+      n.minBreadth = n.firstChild
+          ? n.firstChild.minBreadth
+          : (n.breadth - breadth / 2);
+      n.maxBreadth = n.firstChild
+          ? n.lastChild.maxBreadth
+          : (n.breadth + breadth / 2);
+    });
+  root.visitBefore(function(n) {
+      n.minDepth = n.parentNode
+          ? n.parentNode.maxDepth
+          : 0;
+      n.maxDepth = n.parentNode
+          ? (n.depth + root.depth)
+          : (n.minDepth + 2 * root.depth);
+    });
+  root.minDepth = -depth;
+
+  pv.Layout.Hierarchy.NodeLink.buildImplied.call(this, s);
+};
+
+/**
+ * Constructs a new, empty space-filling cluster layout. Layouts are not
+ * typically constructed directly; instead, they are added to an existing panel
+ * via {@link pv.Mark#add}.
+ *
+ * @class A variant of cluster layout that is space-filling. The meaning of the
+ * exported mark prototypes changes slightly in the space-filling
+ * implementation:<ul>
+ *
+ * <li><tt>node</tt> - for rendering nodes; typically a {@link pv.Bar} for
+ * non-radial orientations, and a {@link pv.Wedge} for radial orientations.
+ *
+ * <p><li><tt>link</tt> - unsupported; undefined. Links are encoded implicitly
+ * in the arrangement of the space-filling nodes.
+ *
+ * <p><li><tt>label</tt> - for rendering node labels; typically a
+ * {@link pv.Label}.
+ *
+ * </ul>For more details on how to use this layout, see
+ * {@link pv.Layout.Cluster}.
+ *
+ * @extends pv.Layout.Cluster
+ */
+pv.Layout.Cluster.Fill = function() {
+  pv.Layout.Cluster.call(this);
+  pv.Layout.Hierarchy.Fill.constructor.call(this);
+};
+
+pv.Layout.Cluster.Fill.prototype = pv.extend(pv.Layout.Cluster);
+
+/** @private */
+pv.Layout.Cluster.Fill.prototype.buildImplied = function(s) {
+  if (pv.Layout.Cluster.prototype.buildImplied.call(this, s)) return;
+  pv.Layout.Hierarchy.Fill.buildImplied.call(this, s);
+};
diff --git a/vendor/protovis/src/layout/Force.js b/vendor/protovis/src/layout/Force.js
new file mode 100644
index 0000000..9bd00f1
--- /dev/null
+++ b/vendor/protovis/src/layout/Force.js
@@ -0,0 +1,309 @@
+/**
+ * Constructs a new, empty force-directed layout. Layouts are not typically
+ * constructed directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class Implements force-directed network layout as a node-link diagram. This
+ * layout uses the Fruchterman-Reingold algorithm, which applies an attractive
+ * spring force between neighboring nodes, and a repulsive electrical charge
+ * force between all nodes. An additional drag force improves stability of the
+ * simulation. See {@link pv.Force.spring}, {@link pv.Force.drag} and {@link
+ * pv.Force.charge} for more details; note that the n-body charge force is
+ * approximated using the Barnes-Hut algorithm.
+ *
+ * <p>This layout is implemented on top of {@link pv.Simulation}, which can be
+ * used directly for more control over simulation parameters. The simulation
+ * uses Position Verlet integration, which does not compute velocities
+ * explicitly, but allows for easy geometric constraints, such as bounding the
+ * nodes within the layout panel. Many of the configuration properties supported
+ * by this layout are simply passed through to the underlying forces and
+ * constraints of the simulation.
+ *
+ * <p>Force layouts are typically interactive. The gradual movement of the nodes
+ * as they stabilize to a local stress minimum can help reveal the structure of
+ * the network, as can {@link pv.Behavior.drag}, which allows the user to pick
+ * up nodes and reposition them while the physics simulation continues. This
+ * layout can also be used with pan & zoom behaviors for interaction.
+ *
+ * <p>To facilitate interaction, this layout by default automatically re-renders
+ * using a <tt>setInterval</tt> every 42 milliseconds. This can be disabled via
+ * the <tt>iterations</tt> property, which if non-null specifies the number of
+ * simulation iterations to run before the force-directed layout is finalized.
+ * Be careful not to use too high an iteration count, as this can lead to an
+ * annoying delay on page load.
+ *
+ * <p>As with other network layouts, the network data can be updated
+ * dynamically, provided the property cache is reset. See
+ * {@link pv.Layout.Network} for details. New nodes are initialized with random
+ * positions near the center. Alternatively, positions can be specified manually
+ * by setting the <tt>x</tt> and <tt>y</tt> attributes on nodes.
+ *
+ * @extends pv.Layout.Network
+ * @see <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.13.8444&rep=rep1&type=pdf"
+ * >"Graph Drawing by Force-directed Placement"</a> by T. Fruchterman &
+ * E. Reingold, Software--Practice & Experience, November 1991.
+ */
+pv.Layout.Force = function() {
+  pv.Layout.Network.call(this);
+
+  /* Force-directed graphs can be messy, so reduce the link width. */
+  this.link.lineWidth(function(d, p) { return Math.sqrt(p.linkValue) * 1.5; });
+  this.label.textAlign("center");
+};
+
+pv.Layout.Force.prototype = pv.extend(pv.Layout.Network)
+    .property("bound", Boolean)
+    .property("iterations", Number)
+    .property("dragConstant", Number)
+    .property("chargeConstant", Number)
+    .property("chargeMinDistance", Number)
+    .property("chargeMaxDistance", Number)
+    .property("chargeTheta", Number)
+    .property("springConstant", Number)
+    .property("springDamping", Number)
+    .property("springLength", Number);
+
+/**
+ * The bound parameter; true if nodes should be constrained within the layout
+ * panel. Bounding is disabled by default. Currently the layout does not observe
+ * the radius of the nodes; strictly speaking, only the center of the node is
+ * constrained to be within the panel, with an additional 6-pixel offset for
+ * padding. A future enhancement could extend the bound constraint to observe
+ * the node's radius, which would also support bounding for variable-size nodes.
+ *
+ * <p>Note that if this layout is used in conjunction with pan & zoom
+ * behaviors, those behaviors should have their bound parameter set to the same
+ * value.
+ *
+ * @type boolean
+ * @name pv.Layout.Force.prototype.bound
+ */
+
+/**
+ * The number of simulation iterations to run, or null if this layout is
+ * interactive. Force-directed layouts are interactive by default, using a
+ * <tt>setInterval</tt> to advance the physics simulation and re-render
+ * automatically.
+ *
+ * @type number
+ * @name pv.Layout.Force.prototype.iterations
+ */
+
+/**
+ * The drag constant, in the range [0,1]. A value of 0 means no drag (a
+ * perfectly frictionless environment), while a value of 1 means friction
+ * immediately cancels all momentum. The default value is 0.1, which provides a
+ * minimum amount of drag that helps stabilize bouncy springs; lower values may
+ * result in excessive bounciness, while higher values cause the simulation to
+ * take longer to converge.
+ *
+ * @type number
+ * @name pv.Layout.Force.prototype.dragConstant
+ * @see pv.Force.drag#constant
+ */
+
+/**
+ * The charge constant, which should be a negative number. The default value is
+ * -40; more negative values will result in a stronger repulsive force, which
+ * may lead to faster convergence at the risk of instability. Too strong
+ * repulsive charge forces can cause comparatively weak springs to be stretched
+ * well beyond their rest length, emphasizing global structure over local
+ * structure. A nonnegative value will break the Fruchterman-Reingold algorithm,
+ * and is for entertainment purposes only.
+ *
+ * @type number
+ * @name pv.Layout.Force.prototype.chargeConstant
+ * @see pv.Force.charge#constant
+ */
+
+/**
+ * The minimum distance at which charge forces are applied. The default minimum
+ * distance of 2 avoids applying forces that are two strong; because the physics
+ * simulation is run at discrete time intervals, it is possible for two same-
+ * charged particles to become very close or even a singularity! Since the
+ * charge force is inversely proportional to the square of the distance, very
+ * small distances can break the simulation.
+ *
+ * <p>In rare cases, two particles can become stuck on top of each other, as a
+ * minimum distance threshold will prevent the charge force from repelling them.
+ * However, this occurs very rarely because other forces and momentum typically
+ * cause the particles to become separated again, at which point the repulsive
+ * charge force kicks in.
+ *
+ * @type number
+ * @name pv.Layout.Force.prototype.chargeMinDistance
+ * @see pv.Force.charge#domain
+ */
+
+/**
+ * The maximum distance at which charge forces are applied. This improves
+ * performance by ignoring weak charge forces at great distances. Note that this
+ * parameter is partly redundant, as the Barnes-Hut algorithm for n-body forces
+ * already improves performance for far-away particles through approximation.
+ *
+ * @type number
+ * @name pv.Layout.Force.prototype.chargeMaxDistance
+ * @see pv.Force.charge#domain
+ */
+
+/**
+ * The Barnes-Hut approximation factor. The Barnes-Hut approximation criterion
+ * is the ratio of the size of the quadtree node to the distance from the point
+ * to the node's center of mass is beneath some threshold. The default value is
+ * 0.9.
+ *
+ * @type number
+ * @name pv.Layout.Force.prototype.chargeTheta
+ * @see pv.Force.charge#theta
+ */
+
+/**
+ * The spring constant, which should be a positive number. The default value is
+ * 0.1; greater values will result in a stronger attractive force, which may
+ * lead to faster convergence at the risk of instability. Too strong spring
+ * forces can cause comparatively weak charge forces to be ignored, emphasizing
+ * local structure over global structure. A nonpositive value will break the
+ * Fruchterman-Reingold algorithm, and is for entertainment purposes only.
+ *
+ * <p>The spring tension is automatically normalized using the inverse square
+ * root of the maximum link degree of attached nodes.
+ *
+ * @type number
+ * @name pv.Layout.Force.prototype.springConstant
+ * @see pv.Force.spring#constant
+ */
+
+/**
+ * The spring damping factor, in the range [0,1]. Damping functions identically
+ * to drag forces, damping spring bounciness by applying a force in the opposite
+ * direction of attached nodes' velocities. The default value is 0.3.
+ *
+ * <p>The spring damping is automatically normalized using the inverse square
+ * root of the maximum link degree of attached nodes.
+ *
+ * @type number
+ * @name pv.Layout.Force.prototype.springDamping
+ * @see pv.Force.spring#damping
+ */
+
+/**
+ * The spring rest length. The default value is 20 pixels. Larger values may be
+ * appropriate if the layout panel is larger, or if the nodes are rendered
+ * larger than the default dot size of 20.
+ *
+ * @type number
+ * @name pv.Layout.Force.prototype.springLength
+ * @see pv.Force.spring#length
+ */
+
+/**
+ * Default properties for force-directed layouts. The default drag constant is
+ * 0.1, the default charge constant is -40 (with a domain of [2, 500] and theta
+ * of 0.9), and the default spring constant is 0.1 (with a damping of 0.3 and a
+ * rest length of 20).
+ *
+ * @type pv.Layout.Force
+ */
+pv.Layout.Force.prototype.defaults = new pv.Layout.Force()
+    .extend(pv.Layout.Network.prototype.defaults)
+    .dragConstant(.1)
+    .chargeConstant(-40)
+    .chargeMinDistance(2)
+    .chargeMaxDistance(500)
+    .chargeTheta(.9)
+    .springConstant(.1)
+    .springDamping(.3)
+    .springLength(20);
+
+/** @private Initialize the physics simulation. */
+pv.Layout.Force.prototype.buildImplied = function(s) {
+
+  /* Any cached interactive layouts need to be rebound for the timer. */
+  if (pv.Layout.Network.prototype.buildImplied.call(this, s)) {
+    var f = s.$force;
+    if (f) {
+      f.next = this.binds.$force;
+      this.binds.$force = f;
+    }
+    return;
+  }
+
+  var that = this,
+      nodes = s.nodes,
+      links = s.links,
+      k = s.iterations,
+      w = s.width,
+      h = s.height;
+
+  /* Initialize positions randomly near the center. */
+  for (var i = 0, n; i < nodes.length; i++) {
+    n = nodes[i];
+    if (isNaN(n.x)) n.x = w / 2 + 40 * Math.random() - 20;
+    if (isNaN(n.y)) n.y = h / 2 + 40 * Math.random() - 20;
+  }
+
+  /* Initialize the simulation. */
+  var sim = pv.simulation(nodes);
+
+  /* Drag force. */
+  sim.force(pv.Force.drag(s.dragConstant));
+
+  /* Charge (repelling) force. */
+  sim.force(pv.Force.charge(s.chargeConstant)
+      .domain(s.chargeMinDistance, s.chargeMaxDistance)
+      .theta(s.chargeTheta));
+
+  /* Spring (attracting) force. */
+  sim.force(pv.Force.spring(s.springConstant)
+      .damping(s.springDamping)
+      .length(s.springLength)
+      .links(links));
+
+  /* Position constraint (for interactive dragging). */
+  sim.constraint(pv.Constraint.position());
+
+  /* Optionally add bound constraint. TODO: better padding. */
+  if (s.bound) {
+    sim.constraint(pv.Constraint.bound().x(6, w - 6).y(6, h - 6));
+  }
+
+  /** @private Returns the speed of the given node, to determine cooling. */
+  function speed(n) {
+    return n.fix ? 1 : n.vx * n.vx + n.vy * n.vy;
+  }
+
+  /*
+   * If the iterations property is null (the default), the layout is
+   * interactive. The simulation is run until the fastest particle drops below
+   * an arbitrary minimum speed. Although the timer keeps firing, this speed
+   * calculation is fast so there is minimal CPU overhead. Note: if a particle
+   * is fixed for interactivity, treat this as a high speed and resume
+   * simulation.
+   */
+  if (k == null) {
+    sim.step(); // compute initial previous velocities
+    sim.step(); // compute initial velocities
+
+    /* Add the simulation state to the bound list. */
+    var force = s.$force = this.binds.$force = {
+      next: this.binds.$force,
+      nodes: nodes,
+      min: 1e-4 * (links.length + 1),
+      sim: sim
+    };
+
+    /* Start the timer, if not already started. */
+    if (!this.$timer) this.$timer = setInterval(function() {
+      var render = false;
+      for (var f = that.binds.$force; f; f = f.next) {
+        if (pv.max(f.nodes, speed) > f.min) {
+          f.sim.step();
+          render = true;
+        }
+      }
+      if (render) that.render();
+    }, 42);
+  } else for (var i = 0; i < k; i++) {
+    sim.step();
+  }
+};
diff --git a/vendor/protovis/src/layout/Grid.js b/vendor/protovis/src/layout/Grid.js
new file mode 100644
index 0000000..13064a8
--- /dev/null
+++ b/vendor/protovis/src/layout/Grid.js
@@ -0,0 +1,119 @@
+/**
+ * Constructs a new, empty grid layout. Layouts are not typically constructed
+ * directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class Implements a grid layout with regularly-sized rows and columns. The
+ * number of rows and columns are determined from their respective
+ * properties. For example, the 2×3 array:
+ *
+ * <pre>1 2 3
+ * 4 5 6</pre>
+ *
+ * can be represented using the <tt>rows</tt> property as:
+ *
+ * <pre>[[1, 2, 3], [4, 5, 6]]</pre>
+ *
+ * If your data is in column-major order, you can equivalently use the
+ * <tt>columns</tt> property. If the <tt>rows</tt> property is an array, it
+ * takes priority over the <tt>columns</tt> property. The data is implicitly
+ * transposed, as if the {@link pv.transpose} operator were applied.
+ *
+ * <p>This layout exports a single <tt>cell</tt> mark prototype, which is
+ * intended to be used with a bar, panel, layout, or subclass thereof. The data
+ * property of the cell prototype is defined as the elements in the array. For
+ * example, if the array is a two-dimensional array of values in the range
+ * [0,1], a simple heatmap can be generated as:
+ *
+ * <pre>vis.add(pv.Layout.Grid)
+ *     .rows(arrays)
+ *   .cell.add(pv.Bar)
+ *     .fillStyle(pv.ramp("white", "black"))</pre>
+ *
+ * The grid subdivides the full width and height of the parent panel into equal
+ * rectangles. Note, however, that for large, interactive, or animated heatmaps,
+ * you may see significantly better performance through dynamic {@link pv.Image}
+ * generation.
+ *
+ * <p>For irregular grids using value-based spatial partitioning, see {@link
+ * pv.Layout.Treemap}.
+ *
+ * @extends pv.Layout
+ */
+pv.Layout.Grid = function() {
+  pv.Layout.call(this);
+  var that = this;
+
+  /**
+   * The cell prototype. This prototype is intended to be used with a bar,
+   * panel, or layout (or subclass thereof) to render the grid cells.
+   *
+   * @type pv.Mark
+   * @name pv.Layout.Grid.prototype.cell
+   */
+  (this.cell = new pv.Mark()
+      .data(function() {
+          return that.scene[that.index].$grid;
+        })
+      .width(function() {
+          return that.width() / that.cols();
+        })
+      .height(function() {
+          return that.height() / that.rows();
+        })
+      .left(function() {
+          return this.width() * (this.index % that.cols());
+        })
+      .top(function() {
+          return this.height() * Math.floor(this.index / that.cols());
+        })).parent = this;
+};
+
+pv.Layout.Grid.prototype = pv.extend(pv.Layout)
+    .property("rows")
+    .property("cols");
+
+/**
+ * Default properties for grid layouts. By default, there is one row and one
+ * column, and the data is the propagated to the child cell.
+ *
+ * @type pv.Layout.Grid
+ */
+pv.Layout.Grid.prototype.defaults = new pv.Layout.Grid()
+    .extend(pv.Layout.prototype.defaults)
+    .rows(1)
+    .cols(1);
+
+/** @private */
+pv.Layout.Grid.prototype.buildImplied = function(s) {
+  pv.Layout.prototype.buildImplied.call(this, s);
+  var r = s.rows, c = s.cols;
+  if (typeof c == "object") r = pv.transpose(c);
+  if (typeof r == "object") {
+    s.$grid = pv.blend(r);
+    s.rows = r.length;
+    s.cols = r[0] ? r[0].length : 0;
+  } else {
+    s.$grid = pv.repeat([s.data], r * c);
+  }
+};
+
+/**
+ * The number of rows. This property can also be specified as the data in
+ * row-major order; in this case, the rows property is implicitly set to the
+ * length of the array, and the cols property is set to the length of the first
+ * element in the array.
+ *
+ * @type number
+ * @name pv.Layout.Grid.prototype.rows
+ */
+
+/**
+ * The number of columns. This property can also be specified as the data in
+ * column-major order; in this case, the cols property is implicitly set to the
+ * length of the array, and the rows property is set to the length of the first
+ * element in the array.
+ *
+ * @type number
+ * @name pv.Layout.Grid.prototype.cols
+ */
diff --git a/vendor/protovis/src/layout/Hierarchy.js b/vendor/protovis/src/layout/Hierarchy.js
new file mode 100644
index 0000000..a01e34d
--- /dev/null
+++ b/vendor/protovis/src/layout/Hierarchy.js
@@ -0,0 +1,249 @@
+/**
+ * Constructs a new, empty hierarchy layout. Layouts are not typically
+ * constructed directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class Represents an abstract layout for hierarchy diagrams. This class is a
+ * specialization of {@link pv.Layout.Network}, providing the basic structure
+ * for both hierarchical node-link diagrams (such as Reingold-Tilford trees) and
+ * space-filling hierarchy diagrams (such as sunbursts and treemaps).
+ *
+ * <p>Unlike general network layouts, the <tt>links</tt> property need not be
+ * defined explicitly. Instead, the links are computed implicitly from the
+ * <tt>parentNode</tt> attribute of the node objects, as defined by the
+ * <tt>nodes</tt> property. This implementation is also available as
+ * {@link #links}, for reuse with non-hierarchical layouts; for example, to
+ * render a tree using force-directed layout.
+ *
+ * <p>Correspondingly, the <tt>nodes</tt> property is represented as a union of
+ * {@link pv.Layout.Network.Node} and {@link pv.Dom.Node}. To construct a node
+ * hierarchy from a simple JSON map, use the {@link pv.Dom} operator; this
+ * operator also provides an easy way to sort nodes before passing them to the
+ * layout.
+ *
+ * <p>For more details on how to use this layout, see
+ * {@link pv.Layout.Network}.
+ *
+ * @see pv.Layout.Cluster
+ * @see pv.Layout.Partition
+ * @see pv.Layout.Tree
+ * @see pv.Layout.Treemap
+ * @see pv.Layout.Indent
+ * @see pv.Layout.Pack
+ * @extends pv.Layout.Network
+ */
+pv.Layout.Hierarchy = function() {
+  pv.Layout.Network.call(this);
+  this.link.strokeStyle("#ccc");
+};
+
+pv.Layout.Hierarchy.prototype = pv.extend(pv.Layout.Network);
+
+/** @private Compute the implied links. (Links are null by default.) */
+pv.Layout.Hierarchy.prototype.buildImplied = function(s) {
+  if (!s.links) s.links = pv.Layout.Hierarchy.links.call(this);
+  pv.Layout.Network.prototype.buildImplied.call(this, s);
+};
+
+/** The implied links; computes links using the <tt>parentNode</tt> attribute. */
+pv.Layout.Hierarchy.links = function() {
+  return this.nodes()
+      .filter(function(n) { return n.parentNode; })
+      .map(function(n) {
+          return {
+              sourceNode: n,
+              targetNode: n.parentNode,
+              linkValue: 1
+            };
+      });
+};
+
+/** @private Provides standard node-link layout based on breadth & depth. */
+pv.Layout.Hierarchy.NodeLink = {
+
+  /** @private */
+  buildImplied: function(s) {
+    var nodes = s.nodes,
+        orient = s.orient,
+        horizontal = /^(top|bottom)$/.test(orient),
+        w = s.width,
+        h = s.height;
+
+    /* Compute default inner and outer radius. */
+    if (orient == "radial") {
+      var ir = s.innerRadius, or = s.outerRadius;
+      if (ir == null) ir = 0;
+      if (or == null) or = Math.min(w, h) / 2;
+    }
+
+    /** @private Returns the radius of the given node. */
+    function radius(n) {
+      return n.parentNode ? (n.depth * (or - ir) + ir) : 0;
+    }
+
+    /** @private Returns the angle of the given node. */
+    function midAngle(n) {
+      return (n.parentNode ? (n.breadth - .25) * 2 * Math.PI : 0);
+    }
+
+    /** @private */
+    function x(n) {
+      switch (orient) {
+        case "left": return n.depth * w;
+        case "right": return w - n.depth * w;
+        case "top": return n.breadth * w;
+        case "bottom": return w - n.breadth * w;
+        case "radial": return w / 2 + radius(n) * Math.cos(n.midAngle);
+      }
+    }
+
+    /** @private */
+    function y(n) {
+      switch (orient) {
+        case "left": return n.breadth * h;
+        case "right": return h - n.breadth * h;
+        case "top": return n.depth * h;
+        case "bottom": return h - n.depth * h;
+        case "radial": return h / 2 + radius(n) * Math.sin(n.midAngle);
+      }
+    }
+
+    for (var i = 0; i < nodes.length; i++) {
+      var n = nodes[i];
+      n.midAngle = orient == "radial" ? midAngle(n)
+          : horizontal ? Math.PI / 2 : 0;
+      n.x = x(n);
+      n.y = y(n);
+      if (n.firstChild) n.midAngle += Math.PI;
+    }
+  }
+};
+
+/** @private Provides standard space-filling layout based on breadth & depth. */
+pv.Layout.Hierarchy.Fill = {
+
+  /** @private */
+  constructor: function() {
+    this.node
+        .strokeStyle("#fff")
+        .fillStyle("#ccc")
+        .width(function(n) { return n.dx; })
+        .height(function(n) { return n.dy; })
+        .innerRadius(function(n) { return n.innerRadius; })
+        .outerRadius(function(n) { return n.outerRadius; })
+        .startAngle(function(n) { return n.startAngle; })
+        .angle(function(n) { return n.angle; });
+
+    this.label
+        .textAlign("center")
+        .left(function(n) { return n.x + (n.dx / 2); })
+        .top(function(n) { return n.y + (n.dy / 2); });
+
+    /* Hide unsupported link. */
+    delete this.link;
+  },
+
+  /** @private */
+  buildImplied: function(s) {
+    var nodes = s.nodes,
+        orient = s.orient,
+        horizontal = /^(top|bottom)$/.test(orient),
+        w = s.width,
+        h = s.height,
+        depth = -nodes[0].minDepth;
+
+    /* Compute default inner and outer radius. */
+    if (orient == "radial") {
+      var ir = s.innerRadius, or = s.outerRadius;
+      if (ir == null) ir = 0;
+      if (ir) depth *= 2; // use full depth step for root
+      if (or == null) or = Math.min(w, h) / 2;
+    }
+
+    /** @private Scales the specified depth for a space-filling layout. */
+    function scale(d, depth) {
+      return (d + depth) / (1 + depth);
+    }
+
+    /** @private */
+    function x(n) {
+      switch (orient) {
+        case "left": return scale(n.minDepth, depth) * w;
+        case "right": return (1 - scale(n.maxDepth, depth)) * w;
+        case "top": return n.minBreadth * w;
+        case "bottom": return (1 - n.maxBreadth) * w;
+        case "radial": return w / 2;
+      }
+    }
+
+    /** @private */
+    function y(n) {
+      switch (orient) {
+        case "left": return n.minBreadth * h;
+        case "right": return (1 - n.maxBreadth) * h;
+        case "top": return scale(n.minDepth, depth) * h;
+        case "bottom": return (1 - scale(n.maxDepth, depth)) * h;
+        case "radial": return h / 2;
+      }
+    }
+
+    /** @private */
+    function dx(n) {
+      switch (orient) {
+        case "left":
+        case "right": return (n.maxDepth - n.minDepth) / (1 + depth) * w;
+        case "top":
+        case "bottom": return (n.maxBreadth - n.minBreadth) * w;
+        case "radial": return n.parentNode ? (n.innerRadius + n.outerRadius) * Math.cos(n.midAngle) : 0;
+      }
+    }
+
+    /** @private */
+    function dy(n) {
+      switch (orient) {
+        case "left":
+        case "right": return (n.maxBreadth - n.minBreadth) * h;
+        case "top":
+        case "bottom": return (n.maxDepth - n.minDepth) / (1 + depth) * h;
+        case "radial": return n.parentNode ? (n.innerRadius + n.outerRadius) * Math.sin(n.midAngle) : 0;
+      }
+    }
+
+    /** @private */
+    function innerRadius(n) {
+      return Math.max(0, scale(n.minDepth, depth / 2)) * (or - ir) + ir;
+    }
+
+    /** @private */
+    function outerRadius(n) {
+      return scale(n.maxDepth, depth / 2) * (or - ir) + ir;
+    }
+
+    /** @private */
+    function startAngle(n) {
+      return (n.parentNode ? n.minBreadth - .25 : 0) * 2 * Math.PI;
+    }
+
+    /** @private */
+    function angle(n) {
+      return (n.parentNode ? n.maxBreadth - n.minBreadth : 1) * 2 * Math.PI;
+    }
+
+    for (var i = 0; i < nodes.length; i++) {
+      var n = nodes[i];
+      n.x = x(n);
+      n.y = y(n);
+      if (orient == "radial") {
+        n.innerRadius = innerRadius(n);
+        n.outerRadius = outerRadius(n);
+        n.startAngle = startAngle(n);
+        n.angle = angle(n);
+        n.midAngle = n.startAngle + n.angle / 2;
+      } else {
+        n.midAngle = horizontal ? -Math.PI / 2 : 0;
+      }
+      n.dx = dx(n);
+      n.dy = dy(n);
+    }
+  }
+};
diff --git a/vendor/protovis/src/layout/Horizon.js b/vendor/protovis/src/layout/Horizon.js
new file mode 100644
index 0000000..e0bd1c6
--- /dev/null
+++ b/vendor/protovis/src/layout/Horizon.js
@@ -0,0 +1,159 @@
+/**
+ * Constructs a new, empty horizon layout. Layouts are not typically constructed
+ * directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class Implements a horizon layout, which is a variation of a single-series
+ * area chart where the area is folded into multiple bands. Color is used to
+ * encode band, allowing the size of the chart to be reduced significantly
+ * without impeding readability. This layout algorithm is based on the work of
+ * J. Heer, N. Kong and M. Agrawala in <a
+ * href="http://hci.stanford.edu/publications/2009/heer-horizon-chi09.pdf">"Sizing
+ * the Horizon: The Effects of Chart Size and Layering on the Graphical
+ * Perception of Time Series Visualizations"</a>, CHI 2009.
+ *
+ * <p>This layout exports a single <tt>band</tt> mark prototype, which is
+ * intended to be used with an area mark. The band mark is contained in a panel
+ * which is replicated per band (and for negative/positive bands). For example,
+ * to create a simple horizon graph given an array of numbers:
+ *
+ * <pre>vis.add(pv.Layout.Horizon)
+ *     .bands(n)
+ *   .band.add(pv.Area)
+ *     .data(data)
+ *     .left(function() this.index * 35)
+ *     .height(function(d) d * 40);</pre>
+ *
+ * The layout can be further customized by changing the number of bands, and
+ * toggling whether the negative bands are mirrored or offset. (See the
+ * above-referenced paper for guidance.)
+ *
+ * <p>The <tt>fillStyle</tt> of the area can be overridden, though typically it
+ * is easier to customize the layout's behavior through the custom
+ * <tt>backgroundStyle</tt>, <tt>positiveStyle</tt> and <tt>negativeStyle</tt>
+ * properties. By default, the background is white, positive bands are blue, and
+ * negative bands are red. For the most accurate presentation, use fully-opaque
+ * colors of equal intensity for the negative and positive bands.
+ *
+ * @extends pv.Layout
+ */
+pv.Layout.Horizon = function() {
+  pv.Layout.call(this);
+  var that = this,
+      bands, // cached bands
+      mode, // cached mode
+      size, // cached height
+      fill, // cached background style
+      red, // cached negative color (ramp)
+      blue, // cached positive color (ramp)
+      buildImplied = this.buildImplied;
+
+  /** @private Cache the layout state to optimize properties. */
+  this.buildImplied = function(s) {
+    buildImplied.call(this, s);
+    bands = s.bands;
+    mode = s.mode;
+    size = Math.round((mode == "color" ? .5 : 1) * s.height);
+    fill = s.backgroundStyle;
+    red = pv.ramp(fill, s.negativeStyle).domain(0, bands);
+    blue = pv.ramp(fill, s.positiveStyle).domain(0, bands);
+  };
+
+  var bands = new pv.Panel()
+      .data(function() { return pv.range(bands * 2); })
+      .overflow("hidden")
+      .height(function() { return size; })
+      .top(function(i) { return mode == "color" ? (i & 1) * size : 0; })
+      .fillStyle(function(i) { return i ? null : fill; });
+
+  /**
+   * The band prototype. This prototype is intended to be used with an Area
+   * mark to render the horizon bands.
+   *
+   * @type pv.Mark
+   * @name pv.Layout.Horizon.prototype.band
+   */
+  this.band = new pv.Mark()
+      .top(function(d, i) {
+          return mode == "mirror" && i & 1
+              ? (i + 1 >> 1) * size
+              : null;
+        })
+      .bottom(function(d, i) {
+          return mode == "mirror"
+              ? (i & 1 ? null : (i + 1 >> 1) * -size)
+              : ((i & 1 || -1) * (i + 1 >> 1) * size);
+        })
+      .fillStyle(function(d, i) {
+          return (i & 1 ? red : blue)((i >> 1) + 1);
+        });
+
+  this.band.add = function(type) {
+    return that.add(pv.Panel).extend(bands).add(type).extend(this);
+  };
+};
+
+pv.Layout.Horizon.prototype = pv.extend(pv.Layout)
+    .property("bands", Number)
+    .property("mode", String)
+    .property("backgroundStyle", pv.color)
+    .property("positiveStyle", pv.color)
+    .property("negativeStyle", pv.color);
+
+/**
+ * Default properties for horizon layouts. By default, there are two bands, the
+ * mode is "offset", the background style is "white", the positive style is
+ * blue, negative style is red.
+ *
+ * @type pv.Layout.Horizon
+ */
+pv.Layout.Horizon.prototype.defaults = new pv.Layout.Horizon()
+    .extend(pv.Layout.prototype.defaults)
+    .bands(2)
+    .mode("offset")
+    .backgroundStyle("white")
+    .positiveStyle("#1f77b4")
+    .negativeStyle("#d62728");
+
+/**
+ * The horizon mode: offset, mirror, or color. The default is "offset".
+ *
+ * @type string
+ * @name pv.Layout.Horizon.prototype.mode
+ */
+
+/**
+ * The number of bands. Must be at least one. The default value is two.
+ *
+ * @type number
+ * @name pv.Layout.Horizon.prototype.bands
+ */
+
+/**
+ * The positive band color; if non-null, the interior of positive bands are
+ * filled with the specified color. The default value of this property is blue.
+ * For accurate blending, this color should be fully opaque.
+ *
+ * @type pv.Color
+ * @name pv.Layout.Horizon.prototype.positiveStyle
+ */
+
+/**
+ * The negative band color; if non-null, the interior of negative bands are
+ * filled with the specified color. The default value of this property is red.
+ * For accurate blending, this color should be fully opaque.
+ *
+ * @type pv.Color
+ * @name pv.Layout.Horizon.prototype.negativeStyle
+ */
+
+/**
+ * The background color. The panel background is filled with the specified
+ * color, and the negative and positive bands are filled with an interpolated
+ * color between this color and the respective band color. The default value of
+ * this property is white. For accurate blending, this color should be fully
+ * opaque.
+ *
+ * @type pv.Color
+ * @name pv.Layout.Horizon.prototype.backgroundStyle
+ */
diff --git a/vendor/protovis/src/layout/Indent.js b/vendor/protovis/src/layout/Indent.js
new file mode 100644
index 0000000..12ca7f3
--- /dev/null
+++ b/vendor/protovis/src/layout/Indent.js
@@ -0,0 +1,83 @@
+/**
+ * Constructs a new, empty indent layout. Layouts are not typically constructed
+ * directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class Implements a hierarchical layout using the indent algorithm. This
+ * layout implements a node-link diagram where the nodes are presented in
+ * preorder traversal, and nodes are indented based on their depth from the
+ * root. This technique is used ubiquitously by operating systems to represent
+ * file directories; although it requires much vertical space, indented trees
+ * allow efficient <i>interactive</i> exploration of trees to find a specific
+ * node. In addition they allow rapid scanning of node labels, and multivariate
+ * data such as file sizes can be displayed adjacent to the hierarchy.
+ *
+ * <p>The indent layout can be configured using the <tt>depth</tt> and
+ * <tt>breadth</tt> properties, which control the increments in pixel space for
+ * each indent and row in the layout. This layout does not support multiple
+ * orientations; the root node is rendered in the top-left, while
+ * <tt>breadth</tt> is a vertical offset from the top, and <tt>depth</tt> is a
+ * horizontal offset from the left.
+ *
+ * <p>For more details on how to use this layout, see
+ * {@link pv.Layout.Hierarchy}.
+ *
+ * @extends pv.Layout.Hierarchy
+ */
+pv.Layout.Indent = function() {
+  pv.Layout.Hierarchy.call(this);
+  this.link.interpolate("step-after");
+};
+
+pv.Layout.Indent.prototype = pv.extend(pv.Layout.Hierarchy)
+    .property("depth", Number)
+    .property("breadth", Number);
+
+/**
+ * The horizontal offset between different levels of the tree; defaults to 15.
+ *
+ * @type number
+ * @name pv.Layout.Indent.prototype.depth
+ */
+
+/**
+ * The vertical offset between nodes; defaults to 15.
+ *
+ * @type number
+ * @name pv.Layout.Indent.prototype.breadth
+ */
+
+/**
+ * Default properties for indent layouts. By default the depth and breadth
+ * offsets are 15 pixels.
+ *
+ * @type pv.Layout.Indent
+ */
+pv.Layout.Indent.prototype.defaults = new pv.Layout.Indent()
+    .extend(pv.Layout.Hierarchy.prototype.defaults)
+    .depth(15)
+    .breadth(15);
+
+/** @private */
+pv.Layout.Indent.prototype.buildImplied = function(s) {
+  if (pv.Layout.Hierarchy.prototype.buildImplied.call(this, s)) return;
+
+  var nodes = s.nodes,
+      bspace = s.breadth,
+      dspace = s.depth,
+      ax = 0,
+      ay = 0;
+
+  /** @private */
+  function position(n, breadth, depth) {
+    n.x = ax + depth++ * dspace;
+    n.y = ay + breadth++ * bspace;
+    n.midAngle = 0;
+    for (var c = n.firstChild; c; c = c.nextSibling) {
+      breadth = position(c, breadth, depth);
+    }
+    return breadth;
+  }
+
+  position(nodes[0], 1, 1);
+};
diff --git a/vendor/protovis/src/layout/Layout.js b/vendor/protovis/src/layout/Layout.js
new file mode 100644
index 0000000..c5de332
--- /dev/null
+++ b/vendor/protovis/src/layout/Layout.js
@@ -0,0 +1,56 @@
+/**
+ * Constructs a new, empty layout with default properties. Layouts are not
+ * typically constructed directly; instead, a concrete subclass is added to an
+ * existing panel via {@link pv.Mark#add}.
+ *
+ * @class Represents an abstract layout, encapsulating a visualization technique
+ * such as a streamgraph or treemap. Layouts are themselves containers,
+ * extending from {@link pv.Panel}, and defining a set of mark prototypes as
+ * children. These mark prototypes provide default properties that together
+ * implement the given visualization technique.
+ *
+ * <p>Layouts do not initially contain any marks; any exported marks (such as a
+ * network layout's <tt>link</tt> and <tt>node</tt>) are intended to be used as
+ * prototypes. By adding a concrete mark, such as a {@link pv.Bar}, to the
+ * appropriate mark prototype, the mark is added to the layout and inherits the
+ * given properties. This approach allows further customization of the layout,
+ * either by choosing a different mark type to add, or more simply by overriding
+ * some of the layout's defined properties.
+ *
+ * <p>Each concrete layout, such as treemap or circle-packing, has different
+ * behavior and may export different mark prototypes, depending on what marks
+ * are typically needed to render the desired visualization. Therefore it is
+ * important to understand how each layout is structured, such that the provided
+ * mark prototypes are used appropriately.
+ *
+ * <p>In addition to the mark prototypes, layouts may define custom properties
+ * that affect the overall behavior of the layout. For example, a treemap layout
+ * might use a property to specify which layout algorithm to use. These
+ * properties are just like other mark properties, and can be defined as
+ * constants or as functions. As with panels, the data property can be used to
+ * replicate layouts, and properties can be defined to in terms of layout data.
+ *
+ * @extends pv.Panel
+ */
+pv.Layout = function() {
+  pv.Panel.call(this);
+};
+
+pv.Layout.prototype = pv.extend(pv.Panel);
+
+/**
+ * @private Defines a local property with the specified name and cast. Note that
+ * although the property method is only defined locally, the cast function is
+ * global, which is necessary since properties are inherited!
+ *
+ * @param {string} name the property name.
+ * @param {function} [cast] the cast function for this property.
+ */
+pv.Layout.prototype.property = function(name, cast) {
+  if (!this.hasOwnProperty("properties")) {
+    this.properties = pv.extend(this.properties);
+  }
+  this.properties[name] = true;
+  this.propertyMethod(name, false, pv.Mark.cast[name] = cast);
+  return this;
+};
diff --git a/vendor/protovis/src/layout/Matrix.js b/vendor/protovis/src/layout/Matrix.js
new file mode 100644
index 0000000..53692d4
--- /dev/null
+++ b/vendor/protovis/src/layout/Matrix.js
@@ -0,0 +1,177 @@
+/**
+ * Constructs a new, empty matrix network layout. Layouts are not typically
+ * constructed directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class Implements a network visualization using a matrix view. This is, in
+ * effect, a visualization of the graph's <i>adjacency matrix</i>: the cell at
+ * row <i>i</i>, column <i>j</i>, corresponds to the link from node <i>i</i> to
+ * node <i>j</i>. The fill color of each cell is binary by default, and
+ * corresponds to whether a link exists between the two nodes. If the underlying
+ * graph has links with variable values, the <tt>fillStyle</tt> property can be
+ * substited to use an appropriate color function, such as {@link pv.ramp}.
+ *
+ * <p>For undirected networks, the matrix is symmetric around the diagonal. For
+ * directed networks, links in opposite directions can be rendered on opposite
+ * sides of the diagonal using <tt>directed(true)</tt>. The graph is assumed to
+ * be undirected by default.
+ *
+ * <p>The mark prototypes for this network layout are slightly different than
+ * other implementations:<ul>
+ *
+ * <li><tt>node</tt> - unsupported; undefined. No mark is needed to visualize
+ * nodes directly, as the nodes are implicit in the location (rows and columns)
+ * of the links.
+ *
+ * <p><li><tt>link</tt> - for rendering links; typically a {@link pv.Bar}. The
+ * link mark is added directly to the layout, with the data property defined as
+ * all possible pairs of nodes. Each pair is represented as a
+ * {@link pv.Network.Layout.Link}, though the <tt>linkValue</tt> attribute may
+ * be 0 if no link exists in the graph.
+ *
+ * <p><li><tt>label</tt> - for rendering node labels; typically a
+ * {@link pv.Label}. The label mark is added directly to the layout, with the
+ * data property defined via the layout's <tt>nodes</tt> property; note,
+ * however, that the nodes are duplicated so as to provide a label across the
+ * top and down the side. Properties such as <tt>strokeStyle</tt> and
+ * <tt>fillStyle</tt> can be overridden to compute properties from node data
+ * dynamically.
+ *
+ * </ul>For more details on how to use this layout, see
+ * {@link pv.Layout.Network}.
+ *
+ * @extends pv.Layout.Network
+ */
+pv.Layout.Matrix = function() {
+  pv.Layout.Network.call(this);
+  var that = this,
+      n, // cached matrix size
+      dx, // cached cell width
+      dy, // cached cell height
+      labels, // cached labels (array of strings)
+      pairs, // cached pairs (array of links)
+      buildImplied = that.buildImplied;
+
+  /** @private Cache layout state to optimize properties. */
+  this.buildImplied = function(s) {
+    buildImplied.call(this, s);
+    n = s.nodes.length;
+    dx = s.width / n;
+    dy = s.height / n;
+    labels = s.$matrix.labels;
+    pairs = s.$matrix.pairs;
+  };
+
+  /* Links are all pairs of nodes. */
+  this.link
+      .data(function() { return pairs; })
+      .left(function() { return dx * (this.index % n); })
+      .top(function() { return dy * Math.floor(this.index / n); })
+      .width(function() { return dx; })
+      .height(function() { return dy; })
+      .lineWidth(1.5)
+      .strokeStyle("#fff")
+      .fillStyle(function(l) { return l.linkValue ? "#555" : "#eee"; })
+      .parent = this;
+
+  /* No special add for links! */
+  delete this.link.add;
+
+  /* Labels are duplicated for top & left. */
+  this.label
+      .data(function() { return labels; })
+      .left(function() { return this.index & 1 ? dx * ((this.index >> 1) + .5) : 0; })
+      .top(function() { return this.index & 1 ? 0 : dy * ((this.index >> 1) + .5); })
+      .textMargin(4)
+      .textAlign(function() { return this.index & 1 ? "left" : "right"; })
+      .textAngle(function() { return this.index & 1 ? -Math.PI / 2 : 0; });
+
+  /* The node mark is unused. */
+  delete this.node;
+};
+
+pv.Layout.Matrix.prototype = pv.extend(pv.Layout.Network)
+    .property("directed", Boolean);
+
+/**
+ * Whether this matrix visualization is directed (bidirectional). By default,
+ * the graph is assumed to be undirected, such that the visualization is
+ * symmetric across the matrix diagonal. If the network is directed, then
+ * forward links are drawn above the diagonal, while reverse links are drawn
+ * below.
+ *
+ * @type boolean
+ * @name pv.Layout.Matrix.prototype.directed
+ */
+
+/**
+ * Specifies an optional sort function. The sort function follows the same
+ * comparator contract required by {@link pv.Dom.Node#sort}. Specifying a sort
+ * function provides an alternative to sort the nodes as they are specified by
+ * the <tt>nodes</tt> property; the main advantage of doing this is that the
+ * comparator function can access implicit fields populated by the network
+ * layout, such as the <tt>linkDegree</tt>.
+ *
+ * <p>Note that matrix visualizations are particularly sensitive to order. This
+ * is referred to as the seriation problem, and many different techniques exist
+ * to find good node orders that emphasize clusters, such as spectral layout and
+ * simulated annealing.
+ *
+ * @param {function} f comparator function for nodes.
+ * @returns {pv.Layout.Matrix} this.
+ */
+pv.Layout.Matrix.prototype.sort = function(f) {
+  this.$sort = f;
+  return this;
+};
+
+/** @private */
+pv.Layout.Matrix.prototype.buildImplied = function(s) {
+  if (pv.Layout.Network.prototype.buildImplied.call(this, s)) return;
+
+  var nodes = s.nodes,
+      links = s.links,
+      sort = this.$sort,
+      n = nodes.length,
+      index = pv.range(n),
+      labels = [],
+      pairs = [],
+      map = {};
+
+  s.$matrix = {labels: labels, pairs: pairs};
+
+  /* Sort the nodes. */
+  if (sort) index.sort(function(a, b) { return sort(nodes[a], nodes[b]); });
+
+  /* Create pairs. */
+  for (var i = 0; i < n; i++) {
+    for (var j = 0; j < n; j++) {
+      var a = index[i],
+          b = index[j],
+          p = {
+            row: i,
+            col: j,
+            sourceNode: nodes[a],
+            targetNode: nodes[b],
+            linkValue: 0
+          };
+      pairs.push(map[a + "." + b] = p);
+    }
+  }
+
+  /* Create labels. */
+  for (var i = 0; i < n; i++) {
+    var a = index[i];
+    labels.push(nodes[a], nodes[a]);
+  }
+
+  /* Accumulate link values. */
+  for (var i = 0; i < links.length; i++) {
+    var l = links[i],
+        source = l.sourceNode.index,
+        target = l.targetNode.index,
+        value = l.linkValue;
+    map[source + "." + target].linkValue += value;
+    if (!s.directed) map[target + "." + source].linkValue += value;
+  }
+};
diff --git a/vendor/protovis/src/layout/Network.js b/vendor/protovis/src/layout/Network.js
new file mode 100644
index 0000000..6a9ff18
--- /dev/null
+++ b/vendor/protovis/src/layout/Network.js
@@ -0,0 +1,302 @@
+/**
+ * Constructs a new, empty network layout. Layouts are not typically constructed
+ * directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class Represents an abstract layout for network diagrams. This class
+ * provides the basic structure for both node-link diagrams (such as
+ * force-directed graph layout) and space-filling network diagrams (such as
+ * sunbursts and treemaps). Note that "network" here is a general term that
+ * includes hierarchical structures; a tree is represented using links from
+ * child to parent.
+ *
+ * <p>Network layouts require the graph data structure to be defined using two
+ * properties:<ul>
+ *
+ * <li><tt>nodes</tt> - an array of objects representing nodes. Objects in this
+ * array must conform to the {@link pv.Layout.Network.Node} interface; which is
+ * to say, be careful to avoid naming collisions with automatic attributes such
+ * as <tt>index</tt> and <tt>linkDegree</tt>. If the nodes property is defined
+ * as an array of primitives, such as numbers or strings, these primitives are
+ * automatically wrapped in an object; the resulting object's <tt>nodeValue</tt>
+ * attribute points to the original primitive value.
+ *
+ * <p><li><tt>links</tt> - an array of objects representing links. Objects in
+ * this array must conform to the {@link pv.Layout.Network.Link} interface; at a
+ * minimum, either <tt>source</tt> and <tt>target</tt> indexes or
+ * <tt>sourceNode</tt> and <tt>targetNode</tt> references must be set. Note that
+ * if the links property is defined after the nodes property, the links can be
+ * defined in terms of <tt>this.nodes()</tt>.
+ *
+ * </ul>
+ *
+ * <p>Three standard mark prototypes are provided:<ul>
+ *
+ * <li><tt>node</tt> - for rendering nodes; typically a {@link pv.Dot}. The node
+ * mark is added directly to the layout, with the data property defined via the
+ * layout's <tt>nodes</tt> property. Properties such as <tt>strokeStyle</tt> and
+ * <tt>fillStyle</tt> can be overridden to compute properties from node data
+ * dynamically.
+ *
+ * <p><li><tt>link</tt> - for rendering links; typically a {@link pv.Line}. The
+ * link mark is added to a child panel, whose data property is defined as
+ * layout's <tt>links</tt> property. The link's data property is then a
+ * two-element array of the source node and target node. Thus, poperties such as
+ * <tt>strokeStyle</tt> and <tt>fillStyle</tt> can be overridden to compute
+ * properties from either the node data (the first argument) or the link data
+ * (the second argument; the parent panel data) dynamically.
+ *
+ * <p><li><tt>label</tt> - for rendering node labels; typically a
+ * {@link pv.Label}. The label mark is added directly to the layout, with the
+ * data property defined via the layout's <tt>nodes</tt> property. Properties
+ * such as <tt>strokeStyle</tt> and <tt>fillStyle</tt> can be overridden to
+ * compute properties from node data dynamically.
+ *
+ * </ul>Note that some network implementations may not support all three
+ * standard mark prototypes; for example, space-filling hierarchical layouts
+ * typically do not use a <tt>link</tt> prototype, as the parent-child links are
+ * implied by the structure of the space-filling <tt>node</tt> marks.  Check the
+ * specific network layout for implementation details.
+ *
+ * <p>Network layout properties, including <tt>nodes</tt> and <tt>links</tt>,
+ * are typically cached rather than re-evaluated with every call to render. This
+ * is a performance optimization, as network layout algorithms can be
+ * expensive. If the network structure changes, call {@link #reset} to clear the
+ * cache before rendering. Note that although the network layout properties are
+ * cached, child mark properties, such as the marks used to render the nodes and
+ * links, <i>are not</i>. Therefore, non-structural changes to the network
+ * layout, such as changing the color of a mark on mouseover, do not need to
+ * reset the layout.
+ *
+ * @see pv.Layout.Hierarchy
+ * @see pv.Layout.Force
+ * @see pv.Layout.Matrix
+ * @see pv.Layout.Arc
+ * @see pv.Layout.Rollup
+ * @extends pv.Layout
+ */
+pv.Layout.Network = function() {
+  pv.Layout.call(this);
+  var that = this;
+
+  /* @private Version tracking to cache layout state, improving performance. */
+  this.$id = pv.id();
+
+  /**
+   * The node prototype. This prototype is intended to be used with a Dot mark
+   * in conjunction with the link prototype.
+   *
+   * @type pv.Mark
+   * @name pv.Layout.Network.prototype.node
+   */
+  (this.node = new pv.Mark()
+      .data(function() { return that.nodes(); })
+      .strokeStyle("#1f77b4")
+      .fillStyle("#fff")
+      .left(function(n) { return n.x; })
+      .top(function(n) { return n.y; })).parent = this;
+
+  /**
+   * The link prototype, which renders edges between source nodes and target
+   * nodes. This prototype is intended to be used with a Line mark in
+   * conjunction with the node prototype.
+   *
+   * @type pv.Mark
+   * @name pv.Layout.Network.prototype.link
+   */
+  this.link = new pv.Mark()
+      .extend(this.node)
+      .data(function(p) { return [p.sourceNode, p.targetNode]; })
+      .fillStyle(null)
+      .lineWidth(function(d, p) { return p.linkValue * 1.5; })
+      .strokeStyle("rgba(0,0,0,.2)");
+
+  this.link.add = function(type) {
+    return that.add(pv.Panel)
+        .data(function() { return that.links(); })
+      .add(type)
+        .extend(this);
+  };
+
+  /**
+   * The node label prototype, which renders the node name adjacent to the node.
+   * This prototype is provided as an alternative to using the anchor on the
+   * node mark; it is primarily intended to be used with radial node-link
+   * layouts, since it provides a convenient mechanism to set the text angle.
+   *
+   * @type pv.Mark
+   * @name pv.Layout.Network.prototype.label
+   */
+  (this.label = new pv.Mark()
+      .extend(this.node)
+      .textMargin(7)
+      .textBaseline("middle")
+      .text(function(n) { return n.nodeName || n.nodeValue; })
+      .textAngle(function(n) {
+          var a = n.midAngle;
+          return pv.Wedge.upright(a) ? a : (a + Math.PI);
+        })
+      .textAlign(function(n) {
+          return pv.Wedge.upright(n.midAngle) ? "left" : "right";
+        })).parent = this;
+};
+
+/**
+ * @class Represents a node in a network layout. There is no explicit
+ * constructor; this class merely serves to document the attributes that are
+ * used on nodes in network layouts. (Note that hierarchical nodes place
+ * additional requirements on node representation, vis {@link pv.Dom.Node}.)
+ *
+ * @see pv.Layout.Network
+ * @name pv.Layout.Network.Node
+ */
+
+/**
+ * The node index, zero-based. This attribute is populated automatically based
+ * on the index in the array returned by the <tt>nodes</tt> property.
+ *
+ * @type number
+ * @name pv.Layout.Network.Node.prototype.index
+ */
+
+/**
+ * The link degree; the sum of link values for all incoming and outgoing links.
+ * This attribute is populated automatically.
+ *
+ * @type number
+ * @name pv.Layout.Network.Node.prototype.linkDegree
+ */
+
+/**
+ * The node name; optional. If present, this attribute will be used to provide
+ * the text for node labels. If not present, the label text will fallback to the
+ * <tt>nodeValue</tt> attribute.
+ *
+ * @type string
+ * @name pv.Layout.Network.Node.prototype.nodeName
+ */
+
+/**
+ * The node value; optional. If present, and no <tt>nodeName</tt> attribute is
+ * present, the node value will be used as the label text. This attribute is
+ * also automatically populated if the nodes are specified as an array of
+ * primitives, such as strings or numbers.
+ *
+ * @type object
+ * @name pv.Layout.Network.Node.prototype.nodeValue
+ */
+
+/**
+ * @class Represents a link in a network layout. There is no explicit
+ * constructor; this class merely serves to document the attributes that are
+ * used on links in network layouts. For hierarchical layouts, this class is
+ * used to represent the parent-child links.
+ *
+ * @see pv.Layout.Network
+ * @name pv.Layout.Network.Link
+ */
+
+/**
+ * The link value, or weight; optional. If not specified (or not a number), the
+ * default value of 1 is used.
+ *
+ * @type number
+ * @name pv.Layout.Network.Link.prototype.linkValue
+ */
+
+/**
+ * The link's source node. If not set, this value will be derived from the
+ * <tt>source</tt> attribute index.
+ *
+ * @type pv.Layout.Network.Node
+ * @name pv.Layout.Network.Link.prototype.sourceNode
+ */
+
+/**
+ * The link's target node. If not set, this value will be derived from the
+ * <tt>target</tt> attribute index.
+ *
+ * @type pv.Layout.Network.Node
+ * @name pv.Layout.Network.Link.prototype.targetNode
+ */
+
+/**
+ * Alias for <tt>sourceNode</tt>, as expressed by the index of the source node.
+ * This attribute is not populated automatically, but may be used as a more
+ * convenient identification of the link's source, for example in a static JSON
+ * representation.
+ *
+ * @type number
+ * @name pv.Layout.Network.Link.prototype.source
+ */
+
+/**
+ * Alias for <tt>targetNode</tt>, as expressed by the index of the target node.
+ * This attribute is not populated automatically, but may be used as a more
+ * convenient identification of the link's target, for example in a static JSON
+ * representation.
+ *
+ * @type number
+ * @name pv.Layout.Network.Link.prototype.target
+ */
+
+/**
+ * Alias for <tt>linkValue</tt>. This attribute is not populated automatically,
+ * but may be used instead of the <tt>linkValue</tt> attribute when specifying
+ * links.
+ *
+ * @type number
+ * @name pv.Layout.Network.Link.prototype.value
+ */
+
+/** @private Transform nodes and links on cast. */
+pv.Layout.Network.prototype = pv.extend(pv.Layout)
+    .property("nodes", function(v) {
+        return v.map(function(d, i) {
+            if (typeof d != "object") d = {nodeValue: d};
+            d.index = i;
+            return d;
+          });
+      })
+    .property("links", function(v) {
+        return v.map(function(d) {
+            if (isNaN(d.linkValue)) d.linkValue = isNaN(d.value) ? 1 : d.value;
+            return d;
+          });
+      });
+
+/**
+ * Resets the cache, such that changes to layout property definitions will be
+ * visible on subsequent render. Unlike normal marks (and normal layouts),
+ * properties associated with network layouts are not automatically re-evaluated
+ * on render; the properties are cached, and any expensive layout algorithms are
+ * only run after the layout is explicitly reset.
+ *
+ * @returns {pv.Layout.Network} this.
+ */
+pv.Layout.Network.prototype.reset = function() {
+  this.$id = pv.id();
+  return this;
+};
+
+/** @private Skip evaluating properties if cached. */
+pv.Layout.Network.prototype.buildProperties = function(s, properties) {
+  if ((s.$id || 0) < this.$id) {
+    pv.Layout.prototype.buildProperties.call(this, s, properties);
+  }
+};
+
+/** @private Compute link degrees; map source and target indexes to nodes. */
+pv.Layout.Network.prototype.buildImplied = function(s) {
+  pv.Layout.prototype.buildImplied.call(this, s);
+  if (s.$id >= this.$id) return true;
+  s.$id = this.$id;
+  s.nodes.forEach(function(d) {
+      d.linkDegree = 0;
+    });
+  s.links.forEach(function(d) {
+      var v = d.linkValue;
+      (d.sourceNode || (d.sourceNode = s.nodes[d.source])).linkDegree += v;
+      (d.targetNode || (d.targetNode = s.nodes[d.target])).linkDegree += v;
+    });
+};
diff --git a/vendor/protovis/src/layout/Pack.js b/vendor/protovis/src/layout/Pack.js
new file mode 100644
index 0000000..0455fea
--- /dev/null
+++ b/vendor/protovis/src/layout/Pack.js
@@ -0,0 +1,323 @@
+/**
+ * Constructs a new, empty circle-packing layout. Layouts are not typically
+ * constructed directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class Implements a hierarchical layout using circle-packing. The meaning of
+ * the exported mark prototypes changes slightly in the space-filling
+ * implementation:<ul>
+ *
+ * <li><tt>node</tt> - for rendering nodes; typically a {@link pv.Dot}.
+ *
+ * <p><li><tt>link</tt> - unsupported; undefined. Links are encoded implicitly
+ * in the arrangement of the space-filling nodes.
+ *
+ * <p><li><tt>label</tt> - for rendering node labels; typically a
+ * {@link pv.Label}.
+ *
+ * </ul>The pack layout support dynamic sizing for leaf nodes, if a
+ * {@link #size} psuedo-property is specified. The default size function returns
+ * 1, causing all leaf nodes to be sized equally, and all internal nodes to be
+ * sized by the number of leaf nodes they have as descendants.
+ *
+ * <p>The size function can be used in conjunction with the order property,
+ * which allows the nodes to the sorted by the computed size. Note: for sorting
+ * based on other data attributes, simply use the default <tt>null</tt> for the
+ * order property, and sort the nodes beforehand using the {@link pv.Dom}
+ * operator.
+ *
+ * <p>For more details on how to use this layout, see
+ * {@link pv.Layout.Hierarchy}.
+ *
+ * @extends pv.Layout.Hierarchy
+ * @see <a href="http://portal.acm.org/citation.cfm?id=1124772.1124851"
+ * >"Visualization of large hierarchical data by circle packing"</a> by W. Wang,
+ * H. Wang, G. Dai, and H. Wang, ACM CHI 2006.
+ */
+pv.Layout.Pack = function() {
+  pv.Layout.Hierarchy.call(this);
+
+  this.node
+      .shapeRadius(function(n) { return n.radius; })
+      .strokeStyle("rgb(31, 119, 180)")
+      .fillStyle("rgba(31, 119, 180, .25)");
+
+  this.label
+      .textAlign("center");
+
+  /* Hide unsupported link. */
+  delete this.link;
+};
+
+pv.Layout.Pack.prototype = pv.extend(pv.Layout.Hierarchy)
+    .property("spacing", Number)
+    .property("order", String); // ascending, descending, reverse, null
+
+/**
+ * Default properties for circle-packing layouts. The default spacing parameter
+ * is 1 and the default order is "ascending".
+ *
+ * @type pv.Layout.Pack
+ */
+pv.Layout.Pack.prototype.defaults = new pv.Layout.Pack()
+    .extend(pv.Layout.Hierarchy.prototype.defaults)
+    .spacing(1)
+    .order("ascending");
+
+/**
+ * The spacing parameter; defaults to 1, which provides a little bit of padding
+ * between sibling nodes and the enclosing circle. Larger values increase the
+ * spacing, by making the sibling nodes smaller; a value of zero makes the leaf
+ * nodes as large as possible, with no padding on enclosing circles.
+ *
+ * @type number
+ * @name pv.Layout.Pack.prototype.spacing
+ */
+
+/**
+ * The sibling node order. The default order is <tt>null</tt>, which means to
+ * use the sibling order specified by the nodes property as-is. A value of
+ * "ascending" will sort siblings in ascending order of size, while "descending"
+ * will do the reverse. For sorting based on data attributes other than size,
+ * use the default <tt>null</tt> for the order property, and sort the nodes
+ * beforehand using the {@link pv.Dom} operator.
+ *
+ * @see pv.Dom.Node#sort
+ * @type string
+ * @name pv.Layout.Pack.prototype.order
+ */
+
+/** @private The default size function. */
+pv.Layout.Pack.prototype.$radius = function() { return 1; };
+
+// TODO is it possible for spacing to operate in pixel space?
+// Right now it appears to be multiples of the smallest radius.
+
+/**
+ * Specifies the sizing function. By default, a sizing function is disabled and
+ * all nodes are given constant size. The sizing function is invoked for each
+ * leaf node in the tree (passed to the constructor).
+ *
+ * <p>For example, if the tree data structure represents a file system, with
+ * files as leaf nodes, and each file has a <tt>bytes</tt> attribute, you can
+ * specify a size function as:
+ *
+ * <pre>    .size(function(d) d.bytes)</pre>
+ *
+ * As with other properties, a size function may specify additional arguments to
+ * access the data associated with the layout and any enclosing panels.
+ *
+ * @param {function} f the new sizing function.
+ * @returns {pv.Layout.Pack} this.
+ */
+pv.Layout.Pack.prototype.size = function(f) {
+  this.$radius = typeof f == "function"
+      ? function() { return Math.sqrt(f.apply(this, arguments)); }
+      : (f = Math.sqrt(f), function() { return f; });
+  return this;
+};
+
+/** @private */
+pv.Layout.Pack.prototype.buildImplied = function(s) {
+  if (pv.Layout.Hierarchy.prototype.buildImplied.call(this, s)) return;
+
+  var that = this,
+      nodes = s.nodes,
+      root = nodes[0];
+
+  /** @private Compute the radii of the leaf nodes. */
+  function radii(nodes) {
+    var stack = pv.Mark.stack;
+    stack.unshift(null);
+    for (var i = 0, n = nodes.length; i < n; i++) {
+      var c = nodes[i];
+      if (!c.firstChild) {
+        c.radius = that.$radius.apply(that, (stack[0] = c, stack));
+      }
+    }
+    stack.shift();
+  }
+
+  /** @private */
+  function packTree(n) {
+    var nodes = [];
+    for (var c = n.firstChild; c; c = c.nextSibling) {
+      if (c.firstChild) c.radius = packTree(c);
+      c.n = c.p = c;
+      nodes.push(c);
+    }
+
+    /* Sort. */
+    switch (s.order) {
+      case "ascending": {
+        nodes.sort(function(a, b) { return a.radius - b.radius; });
+        break;
+      }
+      case "descending": {
+        nodes.sort(function(a, b) { return b.radius - a.radius; });
+        break;
+      }
+      case "reverse": nodes.reverse(); break;
+    }
+
+    return packCircle(nodes);
+  }
+
+  /** @private */
+  function packCircle(nodes) {
+    var xMin = Infinity,
+        xMax = -Infinity,
+        yMin = Infinity,
+        yMax = -Infinity,
+        a, b, c, j, k;
+
+    /** @private */
+    function bound(n) {
+      xMin = Math.min(n.x - n.radius, xMin);
+      xMax = Math.max(n.x + n.radius, xMax);
+      yMin = Math.min(n.y - n.radius, yMin);
+      yMax = Math.max(n.y + n.radius, yMax);
+    }
+
+    /** @private */
+    function insert(a, b) {
+      var c = a.n;
+      a.n = b;
+      b.p = a;
+      b.n = c;
+      c.p = b;
+    }
+
+    /** @private */
+    function splice(a, b) {
+      a.n = b;
+      b.p = a;
+    }
+
+    /** @private */
+    function intersects(a, b) {
+      var dx = b.x - a.x,
+          dy = b.y - a.y,
+          dr = a.radius + b.radius;
+      return (dr * dr - dx * dx - dy * dy) > .001; // within epsilon
+    }
+
+    /* Create first node. */
+    a = nodes[0];
+    a.x = -a.radius;
+    a.y = 0;
+    bound(a);
+
+    /* Create second node. */
+    if (nodes.length > 1) {
+      b = nodes[1];
+      b.x = b.radius;
+      b.y = 0;
+      bound(b);
+
+      /* Create third node and build chain. */
+      if (nodes.length > 2) {
+        c = nodes[2];
+        place(a, b, c);
+        bound(c);
+        insert(a, c);
+        a.p = c;
+        insert(c, b);
+        b = a.n;
+
+        /* Now iterate through the rest. */
+        for (var i = 3; i < nodes.length; i++) {
+          place(a, b, c = nodes[i]);
+
+          /* Search for the closest intersection. */
+          var isect = 0, s1 = 1, s2 = 1;
+          for (j = b.n; j != b; j = j.n, s1++) {
+            if (intersects(j, c)) {
+              isect = 1;
+              break;
+            }
+          }
+          if (isect == 1) {
+            for (k = a.p; k != j.p; k = k.p, s2++) {
+              if (intersects(k, c)) {
+                if (s2 < s1) {
+                  isect = -1;
+                  j = k;
+                }
+                break;
+              }
+            }
+          }
+
+          /* Update node chain. */
+          if (isect == 0) {
+            insert(a, c);
+            b = c;
+            bound(c);
+          } else if (isect > 0) {
+            splice(a, j);
+            b = j;
+            i--;
+          } else if (isect < 0) {
+            splice(j, b);
+            a = j;
+            i--;
+          }
+        }
+      }
+    }
+
+    /* Re-center the circles and return the encompassing radius. */
+    var cx = (xMin + xMax) / 2,
+        cy = (yMin + yMax) / 2,
+        cr = 0;
+    for (var i = 0; i < nodes.length; i++) {
+      var n = nodes[i];
+      n.x -= cx;
+      n.y -= cy;
+      cr = Math.max(cr, n.radius + Math.sqrt(n.x * n.x + n.y * n.y));
+    }
+    return cr + s.spacing;
+  }
+
+  /** @private */
+  function place(a, b, c) {
+    var da = b.radius + c.radius,
+        db = a.radius + c.radius,
+        dx = b.x - a.x,
+        dy = b.y - a.y,
+        dc = Math.sqrt(dx * dx + dy * dy),
+        cos = (db * db + dc * dc - da * da) / (2 * db * dc),
+        theta = Math.acos(cos),
+        x = cos * db,
+        h = Math.sin(theta) * db;
+    dx /= dc;
+    dy /= dc;
+    c.x = a.x + x * dx + h * dy;
+    c.y = a.y + x * dy - h * dx;
+  }
+
+  /** @private */
+  function transform(n, x, y, k) {
+    for (var c = n.firstChild; c; c = c.nextSibling) {
+      c.x += n.x;
+      c.y += n.y;
+      transform(c, x, y, k);
+    }
+    n.x = x + k * n.x;
+    n.y = y + k * n.y;
+    n.radius *= k;
+  }
+
+  radii(nodes);
+
+  /* Recursively compute the layout. */
+  root.x = 0;
+  root.y = 0;
+  root.radius = packTree(root);
+
+  var w = this.width(),
+      h = this.height(),
+      k = 1 / Math.max(2 * root.radius / w, 2 * root.radius / h);
+  transform(root, w / 2, h / 2, k);
+};
diff --git a/vendor/protovis/src/layout/Partition.js b/vendor/protovis/src/layout/Partition.js
new file mode 100644
index 0000000..306e6a8
--- /dev/null
+++ b/vendor/protovis/src/layout/Partition.js
@@ -0,0 +1,203 @@
+/**
+ * Constructs a new, empty partition layout. Layouts are not typically
+ * constructed directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class Implemeents a hierarchical layout using the partition (or sunburst,
+ * icicle) algorithm. This layout provides both node-link and space-filling
+ * implementations of partition diagrams. In many ways it is similar to
+ * {@link pv.Layout.Cluster}, except that leaf nodes are positioned based on
+ * their distance from the root.
+ *
+ * <p>The partition layout support dynamic sizing for leaf nodes, if a
+ * {@link #size} psuedo-property is specified. The default size function returns
+ * 1, causing all leaf nodes to be sized equally, and all internal nodes to be
+ * sized by the number of leaf nodes they have as descendants.
+ *
+ * <p>The size function can be used in conjunction with the order property,
+ * which allows the nodes to the sorted by the computed size. Note: for sorting
+ * based on other data attributes, simply use the default <tt>null</tt> for the
+ * order property, and sort the nodes beforehand using the {@link pv.Dom}
+ * operator.
+ *
+ * <p>For more details on how to use this layout, see
+ * {@link pv.Layout.Hierarchy}.
+ *
+ * @see pv.Layout.Partition.Fill
+ * @extends pv.Layout.Hierarchy
+ */
+pv.Layout.Partition = function() {
+  pv.Layout.Hierarchy.call(this);
+};
+
+pv.Layout.Partition.prototype = pv.extend(pv.Layout.Hierarchy)
+    .property("order", String) // null, ascending, descending?
+    .property("orient", String) // top, left, right, bottom, radial
+    .property("innerRadius", Number)
+    .property("outerRadius", Number);
+
+/**
+ * The sibling node order. The default order is <tt>null</tt>, which means to
+ * use the sibling order specified by the nodes property as-is. A value of
+ * "ascending" will sort siblings in ascending order of size, while "descending"
+ * will do the reverse. For sorting based on data attributes other than size,
+ * use the default <tt>null</tt> for the order property, and sort the nodes
+ * beforehand using the {@link pv.Dom} operator.
+ *
+ * @see pv.Dom.Node#sort
+ * @type string
+ * @name pv.Layout.Partition.prototype.order
+ */
+
+/**
+ * The orientation. The default orientation is "top", which means that the root
+ * node is placed on the top edge, leaf nodes appear at the bottom, and internal
+ * nodes are in-between. The following orientations are supported:<ul>
+ *
+ * <li>left - left-to-right.
+ * <li>right - right-to-left.
+ * <li>top - top-to-bottom.
+ * <li>bottom - bottom-to-top.
+ * <li>radial - radially, with the root at the center.</ul>
+ *
+ * @type string
+ * @name pv.Layout.Partition.prototype.orient
+ */
+
+/**
+ * The inner radius; defaults to 0. This property applies only to radial
+ * orientations, and can be used to compress the layout radially. Note that for
+ * the node-link implementation, the root node is always at the center,
+ * regardless of the value of this property; this property only affects internal
+ * and leaf nodes. For the space-filling implementation, a non-zero value of
+ * this property will result in the root node represented as a ring rather than
+ * a circle.
+ *
+ * @type number
+ * @name pv.Layout.Partition.prototype.innerRadius
+ */
+
+/**
+ * The outer radius; defaults to fill the containing panel, based on the height
+ * and width of the layout. If the layout has no height and width specified, it
+ * will extend to fill the enclosing panel.
+ *
+ * @type number
+ * @name pv.Layout.Partition.prototype.outerRadius
+ */
+
+/**
+ * Default properties for partition layouts. The default orientation is "top".
+ *
+ * @type pv.Layout.Partition
+ */
+pv.Layout.Partition.prototype.defaults = new pv.Layout.Partition()
+    .extend(pv.Layout.Hierarchy.prototype.defaults)
+    .orient("top");
+
+/** @private */
+pv.Layout.Partition.prototype.$size = function() { return 1; };
+
+/**
+ * Specifies the sizing function. By default, a sizing function is disabled and
+ * all nodes are given constant size. The sizing function is invoked for each
+ * leaf node in the tree (passed to the constructor).
+ *
+ * <p>For example, if the tree data structure represents a file system, with
+ * files as leaf nodes, and each file has a <tt>bytes</tt> attribute, you can
+ * specify a size function as:
+ *
+ * <pre>    .size(function(d) d.bytes)</pre>
+ *
+ * As with other properties, a size function may specify additional arguments to
+ * access the data associated with the layout and any enclosing panels.
+ *
+ * @param {function} f the new sizing function.
+ * @returns {pv.Layout.Partition} this.
+ */
+pv.Layout.Partition.prototype.size = function(f) {
+  this.$size = f;
+  return this;
+};
+
+/** @private */
+pv.Layout.Partition.prototype.buildImplied = function(s) {
+  if (pv.Layout.Hierarchy.prototype.buildImplied.call(this, s)) return;
+
+  var that = this,
+      root = s.nodes[0],
+      stack = pv.Mark.stack,
+      maxDepth = 0;
+
+  /* Recursively compute the tree depth and node size. */
+  stack.unshift(null);
+  root.visitAfter(function(n, i) {
+      if (i > maxDepth) maxDepth = i;
+      n.size = n.firstChild
+          ? pv.sum(n.childNodes, function(n) { return n.size; })
+          : that.$size.apply(that, (stack[0] = n, stack));
+    });
+  stack.shift();
+
+  /* Order */
+  switch (s.order) {
+    case "ascending": root.sort(function(a, b) { return a.size - b.size; }); break;
+    case "descending": root.sort(function(b, a) { return a.size - b.size; }); break;
+  }
+
+  /* Compute the unit breadth and depth of each node. */
+  var ds = 1 / maxDepth;
+  root.minBreadth = 0;
+  root.breadth = .5;
+  root.maxBreadth = 1;
+  root.visitBefore(function(n) {
+    var b = n.minBreadth, s = n.maxBreadth - b;
+      for (var c = n.firstChild; c; c = c.nextSibling) {
+        c.minBreadth = b;
+        c.maxBreadth = b += (c.size / n.size) * s;
+        c.breadth = (b + c.minBreadth) / 2;
+      }
+    });
+  root.visitAfter(function(n, i) {
+      n.minDepth = (i - 1) * ds;
+      n.maxDepth = n.depth = i * ds;
+    });
+
+  pv.Layout.Hierarchy.NodeLink.buildImplied.call(this, s);
+};
+
+/**
+ * Constructs a new, empty space-filling partition layout. Layouts are not
+ * typically constructed directly; instead, they are added to an existing panel
+ * via {@link pv.Mark#add}.
+ *
+ * @class A variant of partition layout that is space-filling. The meaning of
+ * the exported mark prototypes changes slightly in the space-filling
+ * implementation:<ul>
+ *
+ * <li><tt>node</tt> - for rendering nodes; typically a {@link pv.Bar} for
+ * non-radial orientations, and a {@link pv.Wedge} for radial orientations.
+ *
+ * <p><li><tt>link</tt> - unsupported; undefined. Links are encoded implicitly
+ * in the arrangement of the space-filling nodes.
+ *
+ * <p><li><tt>label</tt> - for rendering node labels; typically a
+ * {@link pv.Label}.
+ *
+ * </ul>For more details on how to use this layout, see
+ * {@link pv.Layout.Partition}.
+ *
+ * @extends pv.Layout.Partition
+ */
+pv.Layout.Partition.Fill = function() {
+  pv.Layout.Partition.call(this);
+  pv.Layout.Hierarchy.Fill.constructor.call(this);
+};
+
+pv.Layout.Partition.Fill.prototype = pv.extend(pv.Layout.Partition);
+
+/** @private */
+pv.Layout.Partition.Fill.prototype.buildImplied = function(s) {
+  if (pv.Layout.Partition.prototype.buildImplied.call(this, s)) return;
+  pv.Layout.Hierarchy.Fill.buildImplied.call(this, s);
+};
diff --git a/vendor/protovis/src/layout/Rollup.js b/vendor/protovis/src/layout/Rollup.js
new file mode 100644
index 0000000..ae98c08
--- /dev/null
+++ b/vendor/protovis/src/layout/Rollup.js
@@ -0,0 +1,203 @@
+/**
+ * Constructs a new, empty rollup network layout. Layouts are not typically
+ * constructed directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class Implements a network visualization using a node-link diagram where
+ * nodes are rolled up along two dimensions. This implementation is based on the
+ * "PivotGraph" designed by Martin Wattenberg:
+ *
+ * <blockquote>The method is designed for graphs that are "multivariate", i.e.,
+ * where each node is associated with several attributes. Unlike visualizations
+ * which emphasize global graph topology, PivotGraph uses a simple grid-based
+ * approach to focus on the relationship between node attributes &
+ * connections.</blockquote>
+ *
+ * This layout requires two psuedo-properties to be specified, which assign node
+ * positions along the two dimensions {@link #x} and {@link #y}, corresponding
+ * to the left and top properties, respectively. Typically, these functions are
+ * specified using an {@link pv.Scale.ordinal}. Nodes that share the same
+ * position in <i>x</i> and <i>y</i> are "rolled up" into a meta-node, and
+ * similarly links are aggregated between meta-nodes. For example, to construct
+ * a rollup to analyze links by gender and affiliation, first define two ordinal
+ * scales:
+ *
+ * <pre>var x = pv.Scale.ordinal(nodes, function(d) d.gender).split(0, w),
+ *     y = pv.Scale.ordinal(nodes, function(d) d.aff).split(0, h);</pre>
+ *
+ * Next, define the position psuedo-properties:
+ *
+ * <pre>    .x(function(d) x(d.gender))
+ *     .y(function(d) y(d.aff))</pre>
+ *
+ * Linear and other quantitative scales can alternatively be used to position
+ * the nodes along either dimension. Note, however, that the rollup requires
+ * that the positions match exactly, and thus ordinal scales are recommended to
+ * avoid precision errors.
+ *
+ * <p>Note that because this layout provides a visualization of the rolled up
+ * graph, the data properties for the mark prototypes (<tt>node</tt>,
+ * <tt>link</tt> and <tt>label</tt>) are different from most other network
+ * layouts: they reference the rolled-up nodes and links, rather than the nodes
+ * and links of the full network. The underlying nodes and links for each
+ * rolled-up node and link can be accessed via the <tt>nodes</tt> and
+ * <tt>links</tt> attributes, respectively. The aggregated link values for
+ * rolled-up links can similarly be accessed via the <tt>linkValue</tt>
+ * attribute.
+ *
+ * <p>For undirected networks, links are duplicated in both directions. For
+ * directed networks, use <tt>directed(true)</tt>. The graph is assumed to be
+ * undirected by default.
+ *
+ * @extends pv.Layout.Network
+ * @see <a href="http://www.research.ibm.com/visual/papers/pivotgraph.pdf"
+ * >"Visual Exploration of Multivariate Graphs"</a> by M. Wattenberg, CHI 2006.
+ */
+pv.Layout.Rollup = function() {
+  pv.Layout.Network.call(this);
+  var that = this,
+      nodes, // cached rollup nodes
+      links, // cached rollup links
+      buildImplied = that.buildImplied;
+
+  /** @private Cache layout state to optimize properties. */
+  this.buildImplied = function(s) {
+    buildImplied.call(this, s);
+    nodes = s.$rollup.nodes;
+    links = s.$rollup.links;
+  };
+
+  /* Render rollup nodes. */
+  this.node
+      .data(function() { return nodes; })
+      .shapeSize(function(d) { return d.nodes.length * 20; });
+
+  /* Render rollup links. */
+  this.link
+      .interpolate("polar")
+      .eccentricity(.8);
+
+  this.link.add = function(type) {
+    return that.add(pv.Panel)
+        .data(function() { return links; })
+      .add(type)
+        .extend(this);
+  };
+};
+
+pv.Layout.Rollup.prototype = pv.extend(pv.Layout.Network)
+    .property("directed", Boolean);
+
+/**
+ * Whether the underlying network is directed. By default, the graph is assumed
+ * to be undirected, and links are rendered in both directions. If the network
+ * is directed, then forward links are drawn above the diagonal, while reverse
+ * links are drawn below.
+ *
+ * @type boolean
+ * @name pv.Layout.Rollup.prototype.directed
+ */
+
+/**
+ * Specifies the <i>x</i>-position function used to rollup nodes. The rolled up
+ * nodes are positioned horizontally using the return values from the given
+ * function. Typically the function is specified as an ordinal scale. For
+ * single-dimension rollups, a constant value can be specified.
+ *
+ * @param {function} f the <i>x</i>-position function.
+ * @returns {pv.Layout.Rollup} this.
+ * @see pv.Scale.ordinal
+ */
+pv.Layout.Rollup.prototype.x = function(f) {
+  this.$x = pv.functor(f);
+  return this;
+};
+
+/**
+ * Specifies the <i>y</i>-position function used to rollup nodes. The rolled up
+ * nodes are positioned vertically using the return values from the given
+ * function. Typically the function is specified as an ordinal scale. For
+ * single-dimension rollups, a constant value can be specified.
+ *
+ * @param {function} f the <i>y</i>-position function.
+ * @returns {pv.Layout.Rollup} this.
+ * @see pv.Scale.ordinal
+ */
+pv.Layout.Rollup.prototype.y = function(f) {
+  this.$y = pv.functor(f);
+  return this;
+};
+
+/** @private */
+pv.Layout.Rollup.prototype.buildImplied = function(s) {
+  if (pv.Layout.Network.prototype.buildImplied.call(this, s)) return;
+
+  var nodes = s.nodes,
+      links = s.links,
+      directed = s.directed,
+      n = nodes.length,
+      x = [],
+      y = [],
+      rnindex = 0,
+      rnodes = {},
+      rlinks = {};
+
+  /** @private */
+  function id(i) {
+    return x[i] + "," + y[i];
+  }
+
+  /* Iterate over the data, evaluating the x and y functions. */
+  var stack = pv.Mark.stack, o = {parent: this};
+  stack.unshift(null);
+  for (var i = 0; i < n; i++) {
+    o.index = i;
+    stack[0] = nodes[i];
+    x[i] = this.$x.apply(o, stack);
+    y[i] = this.$y.apply(o, stack);
+  }
+  stack.shift();
+
+  /* Compute rollup nodes. */
+  for (var i = 0; i < nodes.length; i++) {
+    var nodeId = id(i),
+        rn = rnodes[nodeId];
+    if (!rn) {
+      rn = rnodes[nodeId] = pv.extend(nodes[i]);
+      rn.index = rnindex++;
+      rn.x = x[i];
+      rn.y = y[i];
+      rn.nodes = [];
+    }
+    rn.nodes.push(nodes[i]);
+  }
+
+  /* Compute rollup links. */
+  for (var i = 0; i < links.length; i++) {
+    var source = links[i].sourceNode,
+        target = links[i].targetNode,
+        rsource = rnodes[id(source.index)],
+        rtarget = rnodes[id(target.index)],
+        reverse = !directed && rsource.index > rtarget.index,
+        linkId = reverse
+            ? rtarget.index + "," + rsource.index
+            : rsource.index + "," + rtarget.index,
+        rl = rlinks[linkId];
+    if (!rl) {
+      rl = rlinks[linkId] = {
+        sourceNode: rsource,
+        targetNode: rtarget,
+        linkValue: 0,
+        links: []
+      };
+    }
+    rl.links.push(links[i]);
+    rl.linkValue += links[i].linkValue;
+  }
+
+  /* Export the rolled up nodes and links to the scene. */
+  s.$rollup = {
+    nodes: pv.values(rnodes),
+    links: pv.values(rlinks)
+  };
+};
diff --git a/vendor/protovis/src/layout/Stack.js b/vendor/protovis/src/layout/Stack.js
new file mode 100644
index 0000000..54d9eed
--- /dev/null
+++ b/vendor/protovis/src/layout/Stack.js
@@ -0,0 +1,391 @@
+/**
+ * Constructs a new, empty stack layout. Layouts are not typically constructed
+ * directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class Implements a layout for stacked visualizations, ranging from simple
+ * stacked bar charts to more elaborate "streamgraphs" composed of stacked
+ * areas. Stack layouts uses length as a visual encoding, as opposed to
+ * position, as the layers do not share an aligned axis.
+ *
+ * <p>Marks can be stacked vertically or horizontally. For example,
+ *
+ * <pre>vis.add(pv.Layout.Stack)
+ *     .layers([[1, 1.2, 1.7, 1.5, 1.7],
+ *              [.5, 1, .8, 1.1, 1.3],
+ *              [.2, .5, .8, .9, 1]])
+ *     .x(function() this.index * 35)
+ *     .y(function(d) d * 40)
+ *   .layer.add(pv.Area);</pre>
+ *
+ * specifies a vertically-stacked area chart, using the default "bottom-left"
+ * orientation with "zero" offset. This visualization can be easily changed into
+ * a streamgraph using the "wiggle" offset, which attempts to minimize change in
+ * slope weighted by layer thickness. See the {@link #offset} property for more
+ * supported streamgraph algorithms.
+ *
+ * <p>In the simplest case, the layer data can be specified as a two-dimensional
+ * array of numbers. The <tt>x</tt> and <tt>y</tt> psuedo-properties are used to
+ * define the thickness of each layer at the given position, respectively; in
+ * the above example of the "bottom-left" orientation, the <tt>x</tt> and
+ * <tt>y</tt> psuedo-properties are equivalent to the <tt>left</tt> and
+ * <tt>height</tt> properties that you might use if you implemented a stacked
+ * area by hand.
+ *
+ * <p>The advantage of using the stack layout is that the baseline, i.e., the
+ * <tt>bottom</tt> property is computed automatically using the specified offset
+ * algorithm. In addition, the order of layers can be computed using a built-in
+ * algorithm via the <tt>order</tt> property.
+ *
+ * <p>With the exception of the "expand" <tt>offset</tt>, the stack layout does
+ * not perform any automatic scaling of data; the values returned from
+ * <tt>x</tt> and <tt>y</tt> specify pixel sizes. To simplify scaling math, use
+ * this layout in conjunction with {@link pv.Scale.linear} or similar.
+ *
+ * <p>In other cases, the <tt>values</tt> psuedo-property can be used to define
+ * the data more flexibly. As with a typical panel & area, the
+ * <tt>layers</tt> property corresponds to the data in the enclosing panel,
+ * while the <tt>values</tt> psuedo-property corresponds to the data for the
+ * area within the panel. For example, given an array of data values:
+ *
+ * <pre>var crimea = [
+ *  { date: "4/1854", wounds: 0, other: 110, disease: 110 },
+ *  { date: "5/1854", wounds: 0, other: 95, disease: 105 },
+ *  { date: "6/1854", wounds: 0, other: 40, disease: 95 },
+ *  ...</pre>
+ *
+ * and a corresponding array of series names:
+ *
+ * <pre>var causes = ["wounds", "other", "disease"];</pre>
+ *
+ * Separate layers can be defined for each cause like so:
+ *
+ * <pre>vis.add(pv.Layout.Stack)
+ *     .layers(causes)
+ *     .values(crimea)
+ *     .x(function(d) x(d.date))
+ *     .y(function(d, p) y(d[p]))
+ *   .layer.add(pv.Area)
+ *     ...</pre>
+ *
+ * As with the panel & area case, the datum that is passed to the
+ * psuedo-properties <tt>x</tt> and <tt>y</tt> are the values (an element in
+ * <tt>crimea</tt>); the second argument is the layer data (a string in
+ * <tt>causes</tt>). Additional arguments specify the data of enclosing panels,
+ * if any.
+ *
+ * @extends pv.Layout
+ */
+pv.Layout.Stack = function() {
+  pv.Layout.call(this);
+  var that = this,
+      /** @ignore */ none = function() { return null; },
+      prop = {t: none, l: none, r: none, b: none, w: none, h: none},
+      values,
+      buildImplied = that.buildImplied;
+
+  /** @private Proxy the given property on the layer. */
+  function proxy(name) {
+    return function() {
+        return prop[name](this.parent.index, this.index);
+      };
+  }
+
+  /** @private Compute the layout! */
+  this.buildImplied = function(s) {
+    buildImplied.call(this, s);
+
+    var data = s.layers,
+        n = data.length,
+        m,
+        orient = s.orient,
+        horizontal = /^(top|bottom)\b/.test(orient),
+        h = this.parent[horizontal ? "height" : "width"](),
+        x = [],
+        y = [],
+        dy = [];
+
+    /*
+     * Iterate over the data, evaluating the values, x and y functions. The
+     * context in which the x and y psuedo-properties are evaluated is a
+     * pseudo-mark that is a grandchild of this layout.
+     */
+    var stack = pv.Mark.stack, o = {parent: {parent: this}};
+    stack.unshift(null);
+    values = [];
+    for (var i = 0; i < n; i++) {
+      dy[i] = [];
+      y[i] = [];
+      o.parent.index = i;
+      stack[0] = data[i];
+      values[i] = this.$values.apply(o.parent, stack);
+      if (!i) m = values[i].length;
+      stack.unshift(null);
+      for (var j = 0; j < m; j++) {
+        stack[0] = values[i][j];
+        o.index = j;
+        if (!i) x[j] = this.$x.apply(o, stack);
+        dy[i][j] = this.$y.apply(o, stack);
+      }
+      stack.shift();
+    }
+    stack.shift();
+
+    /* order */
+    var index;
+    switch (s.order) {
+      case "inside-out": {
+        var max = dy.map(function(v) { return pv.max.index(v); }),
+            map = pv.range(n).sort(function(a, b) { return max[a] - max[b]; }),
+            sums = dy.map(function(v) { return pv.sum(v); }),
+            top = 0,
+            bottom = 0,
+            tops = [],
+            bottoms = [];
+        for (var i = 0; i < n; i++) {
+          var j = map[i];
+          if (top < bottom) {
+            top += sums[j];
+            tops.push(j);
+          } else {
+            bottom += sums[j];
+            bottoms.push(j);
+          }
+        }
+        index = bottoms.reverse().concat(tops);
+        break;
+      }
+      case "reverse": index = pv.range(n - 1, -1, -1); break;
+      default: index = pv.range(n); break;
+    }
+
+    /* offset */
+    switch (s.offset) {
+      case "silohouette": {
+        for (var j = 0; j < m; j++) {
+          var o = 0;
+          for (var i = 0; i < n; i++) o += dy[i][j];
+          y[index[0]][j] = (h - o) / 2;
+        }
+        break;
+      }
+      case "wiggle": {
+        var o = 0;
+        for (var i = 0; i < n; i++) o += dy[i][0];
+        y[index[0]][0] = o = (h - o) / 2;
+        for (var j = 1; j < m; j++) {
+          var s1 = 0, s2 = 0, dx = x[j] - x[j - 1];
+          for (var i = 0; i < n; i++) s1 += dy[i][j];
+          for (var i = 0; i < n; i++) {
+            var s3 = (dy[index[i]][j] - dy[index[i]][j - 1]) / (2 * dx);
+            for (var k = 0; k < i; k++) {
+              s3 += (dy[index[k]][j] - dy[index[k]][j - 1]) / dx;
+            }
+            s2 += s3 * dy[index[i]][j];
+          }
+          y[index[0]][j] = o -= s1 ? s2 / s1 * dx : 0;
+        }
+        break;
+      }
+      case "expand": {
+        for (var j = 0; j < m; j++) {
+          y[index[0]][j] = 0;
+          var k = 0;
+          for (var i = 0; i < n; i++) k += dy[i][j];
+          if (k) {
+            k = h / k;
+            for (var i = 0; i < n; i++) dy[i][j] *= k;
+          } else {
+            k = h / n;
+            for (var i = 0; i < n; i++) dy[i][j] = k;
+          }
+        }
+        break;
+      }
+      default: {
+        for (var j = 0; j < m; j++) y[index[0]][j] = 0;
+        break;
+      }
+    }
+
+    /* Propagate the offset to the other series. */
+    for (var j = 0; j < m; j++) {
+      var o = y[index[0]][j];
+      for (var i = 1; i < n; i++) {
+        o += dy[index[i - 1]][j];
+        y[index[i]][j] = o;
+      }
+    }
+
+    /* Find the property definitions for dynamic substitution. */
+    var i = orient.indexOf("-"),
+        pdy = horizontal ? "h" : "w",
+        px = i < 0 ? (horizontal ? "l" : "b") : orient.charAt(i + 1),
+        py = orient.charAt(0);
+    for (var p in prop) prop[p] = none;
+    prop[px] = function(i, j) { return x[j]; };
+    prop[py] = function(i, j) { return y[i][j]; };
+    prop[pdy] = function(i, j) { return dy[i][j]; };
+  };
+
+  /**
+   * The layer prototype. This prototype is intended to be used with an area,
+   * bar or panel mark (or subclass thereof). Other mark types may be possible,
+   * though note that the stack layout is not currently designed to support
+   * radial stacked visualizations using wedges.
+   *
+   * <p>The layer is not a direct child of the stack layout; a hidden panel is
+   * used to replicate layers.
+   *
+   * @type pv.Mark
+   * @name pv.Layout.Stack.prototype.layer
+   */
+  this.layer = new pv.Mark()
+      .data(function() { return values[this.parent.index]; })
+      .top(proxy("t"))
+      .left(proxy("l"))
+      .right(proxy("r"))
+      .bottom(proxy("b"))
+      .width(proxy("w"))
+      .height(proxy("h"));
+
+  this.layer.add = function(type) {
+    return that.add(pv.Panel)
+        .data(function() { return that.layers(); })
+      .add(type)
+        .extend(this);
+  };
+};
+
+pv.Layout.Stack.prototype = pv.extend(pv.Layout)
+    .property("orient", String)
+    .property("offset", String)
+    .property("order", String)
+    .property("layers");
+
+/**
+ * Default properties for stack layouts. The default orientation is
+ * "bottom-left", the default offset is "zero", and the default layers is
+ * <tt>[[]]</tt>.
+ *
+ * @type pv.Layout.Stack
+ */
+pv.Layout.Stack.prototype.defaults = new pv.Layout.Stack()
+    .extend(pv.Layout.prototype.defaults)
+    .orient("bottom-left")
+    .offset("zero")
+    .layers([[]]);
+
+/** @private */
+pv.Layout.Stack.prototype.$x
+    = /** @private */ pv.Layout.Stack.prototype.$y
+    = function() { return 0; };
+
+/**
+ * The x psuedo-property; determines the position of the value within the layer.
+ * This typically corresponds to the independent variable. For example, with the
+ * default "bottom-left" orientation, this function defines the "left" property.
+ *
+ * @param {function} f the x function.
+ * @returns {pv.Layout.Stack} this.
+ */
+pv.Layout.Stack.prototype.x = function(f) {
+  /** @private */ this.$x = pv.functor(f);
+  return this;
+};
+
+/**
+ * The y psuedo-property; determines the thickness of the layer at the given
+ * value.  This typically corresponds to the dependent variable. For example,
+ * with the default "bottom-left" orientation, this function defines the
+ * "height" property.
+ *
+ * @param {function} f the y function.
+ * @returns {pv.Layout.Stack} this.
+ */
+pv.Layout.Stack.prototype.y = function(f) {
+  /** @private */ this.$y = pv.functor(f);
+  return this;
+};
+
+/** @private The default value function; identity. */
+pv.Layout.Stack.prototype.$values = pv.identity;
+
+/**
+ * The values function; determines the values for a given layer. The default
+ * value is the identity function, which assumes that the layers property is
+ * specified as a two-dimensional (i.e., nested) array.
+ *
+ * @param {function} f the values function.
+ * @returns {pv.Layout.Stack} this.
+ */
+pv.Layout.Stack.prototype.values = function(f) {
+  this.$values = pv.functor(f);
+  return this;
+};
+
+/**
+ * The layer data in row-major order. The value of this property is typically a
+ * two-dimensional (i.e., nested) array, but any array can be used, provided the
+ * values psuedo-property is defined accordingly.
+ *
+ * @type array[]
+ * @name pv.Layout.Stack.prototype.layers
+ */
+
+/**
+ * The layer orientation. The following values are supported:<ul>
+ *
+ * <li>bottom-left == bottom
+ * <li>bottom-right
+ * <li>top-left == top
+ * <li>top-right
+ * <li>left-top
+ * <li>left-bottom == left
+ * <li>right-top
+ * <li>right-bottom == right
+ *
+ * </ul>. The default value is "bottom-left", which means that the layers will
+ * be built from the bottom-up, and the values within layers will be laid out
+ * from left-to-right.
+ *
+ * <p>Note that with non-zero baselines, some orientations may give similar
+ * results. For example, offset("silohouette") centers the layers, resulting in
+ * a streamgraph. Thus, the orientations "bottom-left" and "top-left" will
+ * produce similar results, differing only in the layer order.
+ *
+ * @type string
+ * @name pv.Layout.Stack.prototype.orient
+ */
+
+/**
+ * The layer order. The following values are supported:<ul>
+ *
+ * <li><i>null</i> - use given layer order.
+ * <li>inside-out - sort by maximum value, with balanced order.
+ * <li>reverse - use reverse of given layer order.
+ *
+ * </ul>For details on the inside-out order algorithm, refer to "Stacked Graphs
+ * -- Geometry & Aesthetics" by L. Byron and M. Wattenberg, IEEE TVCG
+ * November/December 2008.
+ *
+ * @type string
+ * @name pv.Layout.Stack.prototype.order
+ */
+
+/**
+ * The layer offset; the y-position of the bottom of the lowest layer. The
+ * following values are supported:<ul>
+ *
+ * <li>zero - use a zero baseline, i.e., the y-axis.
+ * <li>silohouette - center the stream, i.e., ThemeRiver.
+ * <li>wiggle - minimize weighted change in slope.
+ * <li>expand - expand layers to fill the enclosing layout dimensions.
+ *
+ * </ul>For details on these offset algorithms, refer to "Stacked Graphs --
+ * Geometry & Aesthetics" by L. Byron and M. Wattenberg, IEEE TVCG
+ * November/December 2008.
+ *
+ * @type string
+ * @name pv.Layout.Stack.prototype.offset
+ */
diff --git a/vendor/protovis/src/layout/Tree.js b/vendor/protovis/src/layout/Tree.js
new file mode 100644
index 0000000..d450167
--- /dev/null
+++ b/vendor/protovis/src/layout/Tree.js
@@ -0,0 +1,282 @@
+/**
+ * Constructs a new, empty tree layout. Layouts are not typically constructed
+ * directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class Implements a node-link tree diagram using the Reingold-Tilford "tidy"
+ * tree layout algorithm. The specific algorithm used by this layout is based on
+ * <a href="http://citeseer.ist.psu.edu/buchheim02improving.html">"Improving
+ * Walker's Algorithm to Run in Linear Time"</A> by C. Buchheim, M. Jünger
+ * & S. Leipert, Graph Drawing 2002. This layout supports both cartesian and
+ * radial orientations orientations for node-link diagrams.
+ *
+ * <p>The tree layout supports a "group" property, which if true causes siblings
+ * to be positioned closer together than unrelated nodes at the same depth. The
+ * layout can be configured using the <tt>depth</tt> and <tt>breadth</tt>
+ * properties, which control the increments in pixel space between nodes in both
+ * dimensions, similar to the indent layout.
+ *
+ * <p>For more details on how to use this layout, see
+ * {@link pv.Layout.Hierarchy}.
+ *
+ * @extends pv.Layout.Hierarchy
+ */
+pv.Layout.Tree = function() {
+  pv.Layout.Hierarchy.call(this);
+};
+
+pv.Layout.Tree.prototype = pv.extend(pv.Layout.Hierarchy)
+    .property("group", Number)
+    .property("breadth", Number)
+    .property("depth", Number)
+    .property("orient", String);
+
+/**
+ * Default properties for tree layouts. The default orientation is "top", the
+ * default group parameter is 1, and the default breadth and depth offsets are
+ * 15 and 60 respectively.
+ *
+ * @type pv.Layout.Tree
+ */
+pv.Layout.Tree.prototype.defaults = new pv.Layout.Tree()
+    .extend(pv.Layout.Hierarchy.prototype.defaults)
+    .group(1)
+    .breadth(15)
+    .depth(60)
+    .orient("top");
+
+/** @private */
+pv.Layout.Tree.prototype.buildImplied = function(s) {
+  if (pv.Layout.Hierarchy.prototype.buildImplied.call(this, s)) return;
+
+  var nodes = s.nodes,
+      orient = s.orient,
+      depth = s.depth,
+      breadth = s.breadth,
+      group = s.group,
+      w = s.width,
+      h = s.height;
+
+  /** @private */
+  function firstWalk(v) {
+    var l, r, a;
+    if (!v.firstChild) {
+      if (l = v.previousSibling) {
+        v.prelim = l.prelim + distance(v.depth, true);
+      }
+    } else {
+      l = v.firstChild;
+      r = v.lastChild;
+      a = l; // default ancestor
+      for (var c = l; c; c = c.nextSibling) {
+        firstWalk(c);
+        a = apportion(c, a);
+      }
+      executeShifts(v);
+      var midpoint = .5 * (l.prelim + r.prelim);
+      if (l = v.previousSibling) {
+        v.prelim = l.prelim + distance(v.depth, true);
+        v.mod = v.prelim - midpoint;
+      } else {
+        v.prelim = midpoint;
+      }
+    }
+  }
+
+  /** @private */
+  function secondWalk(v, m, depth) {
+    v.breadth = v.prelim + m;
+    m += v.mod;
+    for (var c = v.firstChild; c; c = c.nextSibling) {
+      secondWalk(c, m, depth);
+    }
+  }
+
+  /** @private */
+  function apportion(v, a) {
+    var w = v.previousSibling;
+    if (w) {
+      var vip = v,
+          vop = v,
+          vim = w,
+          vom = v.parentNode.firstChild,
+          sip = vip.mod,
+          sop = vop.mod,
+          sim = vim.mod,
+          som = vom.mod,
+          nr = nextRight(vim),
+          nl = nextLeft(vip);
+      while (nr && nl) {
+        vim = nr;
+        vip = nl;
+        vom = nextLeft(vom);
+        vop = nextRight(vop);
+        vop.ancestor = v;
+        var shift = (vim.prelim + sim) - (vip.prelim + sip) + distance(vim.depth, false);
+        if (shift > 0) {
+          moveSubtree(ancestor(vim, v, a), v, shift);
+          sip += shift;
+          sop += shift;
+        }
+        sim += vim.mod;
+        sip += vip.mod;
+        som += vom.mod;
+        sop += vop.mod;
+        nr = nextRight(vim);
+        nl = nextLeft(vip);
+      }
+      if (nr && !nextRight(vop)) {
+        vop.thread = nr;
+        vop.mod += sim - sop;
+      }
+      if (nl && !nextLeft(vom)) {
+        vom.thread = nl;
+        vom.mod += sip - som;
+        a = v;
+      }
+    }
+    return a;
+  }
+
+  /** @private */
+  function nextLeft(v) {
+    return v.firstChild || v.thread;
+  }
+
+  /** @private */
+  function nextRight(v) {
+    return v.lastChild || v.thread;
+  }
+
+  /** @private */
+  function moveSubtree(wm, wp, shift) {
+    var subtrees = wp.number - wm.number;
+    wp.change -= shift / subtrees;
+    wp.shift += shift;
+    wm.change += shift / subtrees;
+    wp.prelim += shift;
+    wp.mod += shift;
+  }
+
+  /** @private */
+  function executeShifts(v) {
+    var shift = 0, change = 0;
+    for (var c = v.lastChild; c; c = c.previousSibling) {
+      c.prelim += shift;
+      c.mod += shift;
+      change += c.change;
+      shift += c.shift + change;
+    }
+  }
+
+  /** @private */
+  function ancestor(vim, v, a) {
+    return (vim.ancestor.parentNode == v.parentNode) ? vim.ancestor : a;
+  }
+
+  /** @private */
+  function distance(depth, siblings) {
+    return (siblings ? 1 : (group + 1)) / ((orient == "radial") ? depth : 1);
+  }
+
+  /* Initialize temporary layout variables. TODO: store separately. */
+  var root = nodes[0];
+  root.visitAfter(function(v, i) {
+      v.ancestor = v;
+      v.prelim = 0;
+      v.mod = 0;
+      v.change = 0;
+      v.shift = 0;
+      v.number = v.previousSibling ? (v.previousSibling.number + 1) : 0;
+      v.depth = i;
+    });
+
+  /* Compute the layout using Buchheim et al.'s algorithm. */
+  firstWalk(root);
+  secondWalk(root, -root.prelim, 0);
+
+  /** @private Returns the angle of the given node. */
+  function midAngle(n) {
+    return (orient == "radial") ? n.breadth / depth : 0;
+  }
+
+  /** @private */
+  function x(n) {
+    switch (orient) {
+      case "left": return n.depth;
+      case "right": return w - n.depth;
+      case "top":
+      case "bottom": return n.breadth + w / 2;
+      case "radial": return w / 2 + n.depth * Math.cos(midAngle(n));
+    }
+  }
+
+  /** @private */
+  function y(n) {
+    switch (orient) {
+      case "left":
+      case "right": return n.breadth + h / 2;
+      case "top": return n.depth;
+      case "bottom": return h - n.depth;
+      case "radial": return h / 2 + n.depth * Math.sin(midAngle(n));
+    }
+  }
+
+  /* Clear temporary layout variables; transform depth and breadth. */
+  root.visitAfter(function(v) {
+      v.breadth *= breadth;
+      v.depth *= depth;
+      v.midAngle = midAngle(v);
+      v.x = x(v);
+      v.y = y(v);
+      if (v.firstChild) v.midAngle += Math.PI;
+      delete v.breadth;
+      delete v.depth;
+      delete v.ancestor;
+      delete v.prelim;
+      delete v.mod;
+      delete v.change;
+      delete v.shift;
+      delete v.number;
+      delete v.thread;
+    });
+};
+
+/**
+ * The offset between siblings nodes; defaults to 15.
+ *
+ * @type number
+ * @name pv.Layout.Tree.prototype.breadth
+ */
+
+/**
+ * The offset between parent and child nodes; defaults to 60.
+ *
+ * @type number
+ * @name pv.Layout.Tree.prototype.depth
+ */
+
+/**
+ * The orientation. The default orientation is "top", which means that the root
+ * node is placed on the top edge, leaf nodes appear at the bottom, and internal
+ * nodes are in-between. The following orientations are supported:<ul>
+ *
+ * <li>left - left-to-right.
+ * <li>right - right-to-left.
+ * <li>top - top-to-bottom.
+ * <li>bottom - bottom-to-top.
+ * <li>radial - radially, with the root at the center.</ul>
+ *
+ * @type string
+ * @name pv.Layout.Tree.prototype.orient
+ */
+
+/**
+ * The sibling grouping, i.e., whether differentiating space is placed between
+ * sibling groups. The default is 1 (or true), causing sibling leaves to be
+ * separated by one breadth offset. Setting this to false (or 0) causes
+ * non-siblings to be adjacent.
+ *
+ * @type number
+ * @name pv.Layout.Tree.prototype.group
+ */
diff --git a/vendor/protovis/src/layout/Treemap.js b/vendor/protovis/src/layout/Treemap.js
new file mode 100644
index 0000000..c9df86b
--- /dev/null
+++ b/vendor/protovis/src/layout/Treemap.js
@@ -0,0 +1,347 @@
+/**
+ * Constructs a new, empty treemap layout. Layouts are not typically
+ * constructed directly; instead, they are added to an existing panel via
+ * {@link pv.Mark#add}.
+ *
+ * @class Implements a space-filling rectangular layout, with the hierarchy
+ * represented via containment. Treemaps represent nodes as boxes, with child
+ * nodes placed within parent boxes. The size of each box is proportional to the
+ * size of the node in the tree. This particular algorithm is taken from Bruls,
+ * D.M., C. Huizing, and J.J. van Wijk, <a
+ * href="http://www.win.tue.nl/~vanwijk/stm.pdf">"Squarified Treemaps"</a> in
+ * <i>Data Visualization 2000, Proceedings of the Joint Eurographics and IEEE
+ * TCVG Sumposium on Visualization</i>, 2000, pp. 33-42.
+ *
+ * <p>The meaning of the exported mark prototypes changes slightly in the
+ * space-filling implementation:<ul>
+ *
+ * <li><tt>node</tt> - for rendering nodes; typically a {@link pv.Bar}. The node
+ * data is populated with <tt>dx</tt> and <tt>dy</tt> attributes, in addition to
+ * the standard <tt>x</tt> and <tt>y</tt> position attributes.
+ *
+ * <p><li><tt>leaf</tt> - for rendering leaf nodes only, with no fill or stroke
+ * style by default; typically a {@link pv.Panel} or another layout!
+ *
+ * <p><li><tt>link</tt> - unsupported; undefined. Links are encoded implicitly
+ * in the arrangement of the space-filling nodes.
+ *
+ * <p><li><tt>label</tt> - for rendering node labels; typically a
+ * {@link pv.Label}.
+ *
+ * </ul>For more details on how to use this layout, see
+ * {@link pv.Layout.Hierarchy}.
+ *
+ * @extends pv.Layout.Hierarchy
+ */
+pv.Layout.Treemap = function() {
+  pv.Layout.Hierarchy.call(this);
+
+  this.node
+      .strokeStyle("#fff")
+      .fillStyle("rgba(31, 119, 180, .25)")
+      .width(function(n) { return n.dx; })
+      .height(function(n) { return n.dy; });
+
+  this.label
+      .visible(function(n) { return !n.firstChild; })
+      .left(function(n) { return n.x + (n.dx / 2); })
+      .top(function(n) { return n.y + (n.dy / 2); })
+      .textAlign("center")
+      .textAngle(function(n) { return n.dx > n.dy ? 0 : -Math.PI / 2; });
+
+  (this.leaf = new pv.Mark()
+      .extend(this.node)
+      .fillStyle(null)
+      .strokeStyle(null)
+      .visible(function(n) { return !n.firstChild; })).parent = this;
+
+  /* Hide unsupported link. */
+  delete this.link;
+};
+
+pv.Layout.Treemap.prototype = pv.extend(pv.Layout.Hierarchy)
+    .property("round", Boolean)
+    .property("paddingLeft", Number)
+    .property("paddingRight", Number)
+    .property("paddingTop", Number)
+    .property("paddingBottom", Number)
+    .property("mode", String)
+    .property("order", String);
+
+/**
+ * Default propertiess for treemap layouts. The default mode is "squarify" and
+ * the default order is "ascending".
+ *
+ * @type pv.Layout.Treemap
+ */
+pv.Layout.Treemap.prototype.defaults = new pv.Layout.Treemap()
+    .extend(pv.Layout.Hierarchy.prototype.defaults)
+    .mode("squarify") // squarify, slice-and-dice, slice, dice
+    .order("ascending"); // ascending, descending, reverse, null
+
+/**
+ * Whether node sizes should be rounded to integer values. This has a similar
+ * effect to setting <tt>antialias(false)</tt> for node values, but allows the
+ * treemap algorithm to accumulate error related to pixel rounding.
+ *
+ * @type boolean
+ * @name pv.Layout.Treemap.prototype.round
+ */
+
+/**
+ * The left inset between parent add child in pixels. Defaults to 0.
+ *
+ * @type number
+ * @name pv.Layout.Treemap.prototype.paddingLeft
+ * @see #padding
+ */
+
+/**
+ * The right inset between parent add child in pixels. Defaults to 0.
+ *
+ * @type number
+ * @name pv.Layout.Treemap.prototype.paddingRight
+ * @see #padding
+ */
+
+/**
+ * The top inset between parent and child in pixels. Defaults to 0.
+ *
+ * @type number
+ * @name pv.Layout.Treemap.prototype.paddingTop
+ * @see #padding
+ */
+
+/**
+ * The bottom inset between parent and child in pixels. Defaults to 0.
+ *
+ * @type number
+ * @name pv.Layout.Treemap.prototype.paddingBottom
+ * @see #padding
+ */
+
+/**
+ * The treemap algorithm. The default value is "squarify". The "slice-and-dice"
+ * algorithm may also be used, which alternates between horizontal and vertical
+ * slices for different depths. In addition, the "slice" and "dice" algorithms
+ * may be specified explicitly to control whether horizontal or vertical slices
+ * are used, which may be useful for nested treemap layouts.
+ *
+ * @type string
+ * @name pv.Layout.Treemap.prototype.mode
+ * @see <a
+ * href="ftp://ftp.cs.umd.edu/pub/hcil/Reports-Abstracts-Bibliography/2001-06html/2001-06.pdf"
+ * >"Ordered Treemap Layouts"</a> by B. Shneiderman & M. Wattenberg, IEEE
+ * InfoVis 2001.
+ */
+
+/**
+ * The sibling node order. A <tt>null</tt> value means to use the sibling order
+ * specified by the nodes property as-is; "reverse" will reverse the given
+ * order. The default value "ascending" will sort siblings in ascending order of
+ * size, while "descending" will do the reverse. For sorting based on data
+ * attributes other than size, use the default <tt>null</tt> for the order
+ * property, and sort the nodes beforehand using the {@link pv.Dom} operator.
+ *
+ * @type string
+ * @name pv.Layout.Treemap.prototype.order
+ */
+
+/**
+ * Alias for setting the left, right, top and bottom padding properties
+ * simultaneously.
+ *
+ * @see #paddingLeft
+ * @see #paddingRight
+ * @see #paddingTop
+ * @see #paddingBottom
+ * @returns {pv.Layout.Treemap} this.
+ */
+pv.Layout.Treemap.prototype.padding = function(n) {
+  return this.paddingLeft(n).paddingRight(n).paddingTop(n).paddingBottom(n);
+};
+
+/** @private The default size function. */
+pv.Layout.Treemap.prototype.$size = function(d) {
+  return Number(d.nodeValue);
+};
+
+/**
+ * Specifies the sizing function. By default, the size function uses the
+ * <tt>nodeValue</tt> attribute of nodes as a numeric value: <tt>function(d)
+ * Number(d.nodeValue)</tt>.
+ *
+ * <p>The sizing function is invoked for each leaf node in the tree, per the
+ * <tt>nodes</tt> property. For example, if the tree data structure represents a
+ * file system, with files as leaf nodes, and each file has a <tt>bytes</tt>
+ * attribute, you can specify a size function as:
+ *
+ * <pre>    .size(function(d) d.bytes)</pre>
+ *
+ * @param {function} f the new sizing function.
+ * @returns {pv.Layout.Treemap} this.
+ */
+pv.Layout.Treemap.prototype.size = function(f) {
+  this.$size = pv.functor(f);
+  return this;
+};
+
+/** @private */
+pv.Layout.Treemap.prototype.buildImplied = function(s) {
+  if (pv.Layout.Hierarchy.prototype.buildImplied.call(this, s)) return;
+
+  var that = this,
+      nodes = s.nodes,
+      root = nodes[0],
+      stack = pv.Mark.stack,
+      left = s.paddingLeft,
+      right = s.paddingRight,
+      top = s.paddingTop,
+      bottom = s.paddingBottom,
+      /** @ignore */ size = function(n) { return n.size; },
+      round = s.round ? Math.round : Number,
+      mode = s.mode;
+
+  /** @private */
+  function slice(row, sum, horizontal, x, y, w, h) {
+    for (var i = 0, d = 0; i < row.length; i++) {
+      var n = row[i];
+      if (horizontal) {
+        n.x = x + d;
+        n.y = y;
+        d += n.dx = round(w * n.size / sum);
+        n.dy = h;
+      } else {
+        n.x = x;
+        n.y = y + d;
+        n.dx = w;
+        d += n.dy = round(h * n.size / sum);
+      }
+    }
+    if (n) { // correct on-axis rounding error
+      if (horizontal) {
+        n.dx += w - d;
+      } else {
+        n.dy += h - d;
+      }
+    }
+  }
+
+  /** @private */
+  function ratio(row, l) {
+    var rmax = -Infinity, rmin = Infinity, s = 0;
+    for (var i = 0; i < row.length; i++) {
+      var r = row[i].size;
+      if (r < rmin) rmin = r;
+      if (r > rmax) rmax = r;
+      s += r;
+    }
+    s = s * s;
+    l = l * l;
+    return Math.max(l * rmax / s, s / (l * rmin));
+  }
+
+  /** @private */
+  function layout(n, i) {
+    var x = n.x + left,
+        y = n.y + top,
+        w = n.dx - left - right,
+        h = n.dy - top - bottom;
+
+    /* Assume squarify by default. */
+    if (mode != "squarify") {
+      slice(n.childNodes, n.size,
+          mode == "slice" ? true
+          : mode == "dice" ? false
+          : i & 1, x, y, w, h);
+      return;
+    }
+
+    var row = [],
+        mink = Infinity,
+        l = Math.min(w, h),
+        k = w * h / n.size;
+
+    /* Abort if the size is nonpositive. */
+    if (n.size <= 0) return;
+
+    /* Scale the sizes to fill the current subregion. */
+    n.visitBefore(function(n) { n.size *= k; });
+
+    /** @private Position the specified nodes along one dimension. */
+    function position(row) {
+      var horizontal = w == l,
+          sum = pv.sum(row, size),
+          r = l ? round(sum / l) : 0;
+      slice(row, sum, horizontal, x, y, horizontal ? w : r, horizontal ? r : h);
+      if (horizontal) {
+        y += r;
+        h -= r;
+      } else {
+        x += r;
+        w -= r;
+      }
+      l = Math.min(w, h);
+      return horizontal;
+    }
+
+    var children = n.childNodes.slice(); // copy
+    while (children.length) {
+      var child = children[children.length - 1];
+      if (!child.size) {
+        children.pop();
+        continue;
+      }
+      row.push(child);
+
+      var k = ratio(row, l);
+      if (k <= mink) {
+        children.pop();
+        mink = k;
+      } else {
+        row.pop();
+        position(row);
+        row.length = 0;
+        mink = Infinity;
+      }
+    }
+
+    /* correct off-axis rounding error */
+    if (position(row)) for (var i = 0; i < row.length; i++) {
+      row[i].dy += h;
+    } else for (var i = 0; i < row.length; i++) {
+      row[i].dx += w;
+    }
+  }
+
+  /* Recursively compute the node depth and size. */
+  stack.unshift(null);
+  root.visitAfter(function(n, i) {
+      n.depth = i;
+      n.x = n.y = n.dx = n.dy = 0;
+      n.size = n.firstChild
+          ? pv.sum(n.childNodes, function(n) { return n.size; })
+          : that.$size.apply(that, (stack[0] = n, stack));
+    });
+  stack.shift();
+
+  /* Sort. */
+  switch (s.order) {
+    case "ascending": {
+      root.sort(function(a, b) { return a.size - b.size; });
+      break;
+    }
+    case "descending": {
+      root.sort(function(a, b) { return b.size - a.size; });
+      break;
+    }
+    case "reverse": root.reverse(); break;
+  }
+
+  /* Recursively compute the layout. */
+  root.x = 0;
+  root.y = 0;
+  root.dx = s.width;
+  root.dy = s.height;
+  root.visitBefore(layout);
+};
diff --git a/vendor/protovis/src/mark/Anchor.js b/vendor/protovis/src/mark/Anchor.js
new file mode 100644
index 0000000..1dbf74d
--- /dev/null
+++ b/vendor/protovis/src/mark/Anchor.js
@@ -0,0 +1,81 @@
+/**
+ * Constructs a new mark anchor with default properties.
+ *
+ * @class Represents an anchor on a given mark. An anchor is itself a mark, but
+ * without a visual representation. It serves only to provide useful default
+ * properties that can be inherited by other marks. Each type of mark can define
+ * any number of named anchors for convenience. If the concrete mark type does
+ * not define an anchor implementation specifically, one will be inherited from
+ * the mark's parent class.
+ *
+ * <p>For example, the bar mark provides anchors for its four sides: left,
+ * right, top and bottom. Adding a label to the top anchor of a bar,
+ *
+ * <pre>bar.anchor("top").add(pv.Label);</pre>
+ *
+ * will render a text label on the top edge of the bar; the top anchor defines
+ * the appropriate position properties (top and left), as well as text-rendering
+ * properties for convenience (textAlign and textBaseline).
+ *
+ * <p>Note that anchors do not <i>inherit</i> from their targets; the positional
+ * properties are copied from the scene graph, which guarantees that the anchors
+ * are positioned correctly, even if the positional properties are not defined
+ * deterministically. (In addition, it also improves performance by avoiding
+ * re-evaluating expensive properties.) If you want the anchor to inherit from
+ * the target, use {@link pv.Mark#extend} before adding. For example:
+ *
+ * <pre>bar.anchor("top").extend(bar).add(pv.Label);</pre>
+ *
+ * The anchor defines it's own positional properties, but other properties (such
+ * as the title property, say) can be inherited using the above idiom. Also note
+ * that you can override positional properties in the anchor for custom
+ * behavior.
+ *
+ * @extends pv.Mark
+ * @param {pv.Mark} target the anchor target.
+ */
+pv.Anchor = function(target) {
+  pv.Mark.call(this);
+  this.target = target;
+  this.parent = target.parent;
+};
+
+pv.Anchor.prototype = pv.extend(pv.Mark)
+    .property("name", String);
+
+/**
+ * The anchor name. The set of supported anchor names is dependent on the
+ * concrete mark type; see the mark type for details. For example, bars support
+ * left, right, top and bottom anchors.
+ *
+ * <p>While anchor names are typically constants, the anchor name is a true
+ * property, which means you can specify a function to compute the anchor name
+ * dynamically. For instance, if you wanted to alternate top and bottom anchors,
+ * saying
+ *
+ * <pre>m.anchor(function() (this.index % 2) ? "top" : "bottom").add(pv.Dot);</pre>
+ *
+ * would have the desired effect.
+ *
+ * @type string
+ * @name pv.Anchor.prototype.name
+ */
+
+/**
+ * Sets the prototype of this anchor to the specified mark. Any properties not
+ * defined on this mark may be inherited from the specified prototype mark, or
+ * its prototype, and so on. The prototype mark need not be the same type of
+ * mark as this mark. (Note that for inheritance to be useful, properties with
+ * the same name on different mark types should have equivalent meaning.)
+ *
+ * <p>This method differs slightly from the normal mark behavior in that the
+ * anchor's target is preserved.
+ *
+ * @param {pv.Mark} proto the new prototype.
+ * @returns {pv.Anchor} this anchor.
+ * @see pv.Mark#add
+ */
+pv.Anchor.prototype.extend = function(proto) {
+  this.proto = proto;
+  return this;
+};
diff --git a/vendor/protovis/src/mark/Area.js b/vendor/protovis/src/mark/Area.js
new file mode 100644
index 0000000..dacfc48
--- /dev/null
+++ b/vendor/protovis/src/mark/Area.js
@@ -0,0 +1,268 @@
+/**
+ * Constructs a new area mark with default properties. Areas are not typically
+ * constructed directly, but by adding to a panel or an existing mark via
+ * {@link pv.Mark#add}.
+ *
+ * @class Represents an area mark: the solid area between two series of
+ * connected line segments. Unsurprisingly, areas are used most frequently for
+ * area charts.
+ *
+ * <p>Just as a line represents a polyline, the <tt>Area</tt> mark type
+ * represents a <i>polygon</i>. However, an area is not an arbitrary polygon;
+ * vertices are paired either horizontally or vertically into parallel
+ * <i>spans</i>, and each span corresponds to an associated datum. Either the
+ * width or the height must be specified, but not both; this determines whether
+ * the area is horizontally-oriented or vertically-oriented.  Like lines, areas
+ * can be stroked and filled with arbitrary colors.
+ *
+ * <p>See also the <a href="../../api/Area.html">Area guide</a>.
+ *
+ * @extends pv.Mark
+ */
+pv.Area = function() {
+  pv.Mark.call(this);
+};
+
+pv.Area.prototype = pv.extend(pv.Mark)
+    .property("width", Number)
+    .property("height", Number)
+    .property("lineWidth", Number)
+    .property("strokeStyle", pv.color)
+    .property("fillStyle", pv.color)
+    .property("segmented", Boolean)
+    .property("interpolate", String)
+    .property("tension", Number);
+
+pv.Area.prototype.type = "area";
+
+/**
+ * The width of a given span, in pixels; used for horizontal spans. If the width
+ * is specified, the height property should be 0 (the default). Either the top
+ * or bottom property should be used to space the spans vertically, typically as
+ * a multiple of the index.
+ *
+ * @type number
+ * @name pv.Area.prototype.width
+ */
+
+/**
+ * The height of a given span, in pixels; used for vertical spans. If the height
+ * is specified, the width property should be 0 (the default). Either the left
+ * or right property should be used to space the spans horizontally, typically
+ * as a multiple of the index.
+ *
+ * @type number
+ * @name pv.Area.prototype.height
+ */
+
+/**
+ * The width of stroked lines, in pixels; used in conjunction with
+ * <tt>strokeStyle</tt> to stroke the perimeter of the area. Unlike the
+ * {@link Line} mark type, the entire perimeter is stroked, rather than just one
+ * edge. The default value of this property is 1.5, but since the default stroke
+ * style is null, area marks are not stroked by default.
+ *
+ * <p>This property is <i>fixed</i> for non-segmented areas. See
+ * {@link pv.Mark}.
+ *
+ * @type number
+ * @name pv.Area.prototype.lineWidth
+ */
+
+/**
+ * The style of stroked lines; used in conjunction with <tt>lineWidth</tt> to
+ * stroke the perimeter of the area. Unlike the {@link Line} mark type, the
+ * entire perimeter is stroked, rather than just one edge. The default value of
+ * this property is null, meaning areas are not stroked by default.
+ *
+ * <p>This property is <i>fixed</i> for non-segmented areas. See
+ * {@link pv.Mark}.
+ *
+ * @type string
+ * @name pv.Area.prototype.strokeStyle
+ * @see pv.color
+ */
+
+/**
+ * The area fill style; if non-null, the interior of the polygon forming the
+ * area is filled with the specified color. The default value of this property
+ * is a categorical color.
+ *
+ * <p>This property is <i>fixed</i> for non-segmented areas. See
+ * {@link pv.Mark}.
+ *
+ * @type string
+ * @name pv.Area.prototype.fillStyle
+ * @see pv.color
+ */
+
+/**
+ * Whether the area is segmented; whether variations in fill style, stroke
+ * style, and the other properties are treated as fixed. Rendering segmented
+ * areas is noticeably slower than non-segmented areas.
+ *
+ * <p>This property is <i>fixed</i>. See {@link pv.Mark}.
+ *
+ * @type boolean
+ * @name pv.Area.prototype.segmented
+ */
+
+/**
+ * How to interpolate between values. Linear interpolation ("linear") is the
+ * default, producing a straight line between points. For piecewise constant
+ * functions (i.e., step functions), either "step-before" or "step-after" can be
+ * specified. To draw open uniform b-splines, specify "basis". To draw cardinal
+ * splines, specify "cardinal"; see also {@link #tension}.
+ *
+ * <p>This property is <i>fixed</i>. See {@link pv.Mark}.
+ *
+ * @type string
+ * @name pv.Area.prototype.interpolate
+ */
+
+/**
+ * The tension of cardinal splines; used in conjunction with
+ * interpolate("cardinal"). A value between 0 and 1 draws cardinal splines with
+ * the given tension. In some sense, the tension can be interpreted as the
+ * "length" of the tangent; a tension of 1 will yield all zero tangents (i.e.,
+ * linear interpolation), and a tension of 0 yields a Catmull-Rom spline. The
+ * default value is 0.7.
+ *
+ * <p>This property is <i>fixed</i>. See {@link pv.Mark}.
+ *
+ * @type number
+ * @name pv.Area.prototype.tension
+ */
+
+/**
+ * Default properties for areas. By default, there is no stroke and the fill
+ * style is a categorical color.
+ *
+ * @type pv.Area
+ */
+pv.Area.prototype.defaults = new pv.Area()
+    .extend(pv.Mark.prototype.defaults)
+    .lineWidth(1.5)
+    .fillStyle(pv.Colors.category20().by(pv.parent))
+    .interpolate("linear")
+    .tension(.7);
+
+/** @private Sets width and height to zero if null. */
+pv.Area.prototype.buildImplied = function(s) {
+  if (s.height == null) s.height = 0;
+  if (s.width == null) s.width = 0;
+  pv.Mark.prototype.buildImplied.call(this, s);
+};
+
+/** @private Records which properties may be fixed. */
+pv.Area.fixed = {
+  lineWidth: 1,
+  lineJoin: 1,
+  strokeStyle: 1,
+  fillStyle: 1,
+  segmented: 1,
+  interpolate: 1,
+  tension: 1
+};
+
+/**
+ * @private Make segmented required, such that this fixed property is always
+ * evaluated, even if the first segment is not visible. Also cache which
+ * properties are normally fixed.
+ */
+pv.Area.prototype.bind = function() {
+  pv.Mark.prototype.bind.call(this);
+  var binds = this.binds,
+      required = binds.required,
+      optional = binds.optional;
+  for (var i = 0, n = optional.length; i < n; i++) {
+    var p = optional[i];
+    p.fixed = p.name in pv.Area.fixed;
+    if (p.name == "segmented") {
+      required.push(p);
+      optional.splice(i, 1);
+      i--;
+      n--;
+    }
+  }
+
+  /* Cache the original arrays so they can be restored on build. */
+  this.binds.$required = required;
+  this.binds.$optional = optional;
+};
+
+/**
+ * @private Override the default build behavior such that fixed properties are
+ * determined dynamically, based on the value of the (always) fixed segmented
+ * property. Any fixed properties are only evaluated on the first instance,
+ * although their values are propagated to subsequent instances, so that they
+ * are available for property chaining and the like.
+ */
+pv.Area.prototype.buildInstance = function(s) {
+  var binds = this.binds;
+
+  /* Handle fixed properties on secondary instances. */
+  if (this.index) {
+    var fixed = binds.fixed;
+
+    /* Determine which properties are fixed. */
+    if (!fixed) {
+      fixed = binds.fixed = [];
+      function f(p) { return !p.fixed || (fixed.push(p), false); }
+      binds.required = binds.required.filter(f);
+      if (!this.scene[0].segmented) binds.optional = binds.optional.filter(f);
+    }
+
+    /* Copy fixed property values from the first instance. */
+    for (var i = 0, n = fixed.length; i < n; i++) {
+      var p = fixed[i].name;
+      s[p] = this.scene[0][p];
+    }
+  }
+
+  /* Evaluate all properties on the first instance. */
+  else {
+    binds.required = binds.$required;
+    binds.optional = binds.$optional;
+    binds.fixed = null;
+  }
+
+  pv.Mark.prototype.buildInstance.call(this, s);
+};
+
+/**
+ * Constructs a new area anchor with default properties. Areas support five
+ * different anchors:<ul>
+ *
+ * <li>top
+ * <li>left
+ * <li>center
+ * <li>bottom
+ * <li>right
+ *
+ * </ul>In addition to positioning properties (left, right, top bottom), the
+ * anchors support text rendering properties (text-align, text-baseline). Text
+ * is rendered to appear inside the area. The area anchor also propagates the
+ * interpolate, eccentricity, and tension properties such that an anchored area
+ * or line will match positions between control points.
+ *
+ * <p>For consistency with the other mark types, the anchor positions are
+ * defined in terms of their opposite edge. For example, the top anchor defines
+ * the bottom property, such that an area added to the top anchor grows upward.
+ *
+ * @param {string} name the anchor name; either a string or a property function.
+ * @returns {pv.Anchor}
+ */
+pv.Area.prototype.anchor = function(name) {
+  var scene;
+  return pv.Mark.prototype.anchor.call(this, name)
+    .interpolate(function() {
+       return this.scene.target[this.index].interpolate;
+      })
+    .eccentricity(function() {
+       return this.scene.target[this.index].eccentricity;
+      })
+    .tension(function() {
+        return this.scene.target[this.index].tension;
+      });
+};
diff --git a/vendor/protovis/src/mark/Bar.js b/vendor/protovis/src/mark/Bar.js
new file mode 100644
index 0000000..b1b7e1f
--- /dev/null
+++ b/vendor/protovis/src/mark/Bar.js
@@ -0,0 +1,93 @@
+/**
+ * Constructs a new bar mark with default properties. Bars are not typically
+ * constructed directly, but by adding to a panel or an existing mark via
+ * {@link pv.Mark#add}.
+ *
+ * @class Represents a bar: an axis-aligned rectangle that can be stroked and
+ * filled. Bars are used for many chart types, including bar charts, histograms
+ * and Gantt charts. Bars can also be used as decorations, for example to draw a
+ * frame border around a panel; in fact, a panel is a special type (a subclass)
+ * of bar.
+ *
+ * <p>Bars can be positioned in several ways. Most commonly, one of the four
+ * corners is fixed using two margins, and then the width and height properties
+ * determine the extent of the bar relative to this fixed location. For example,
+ * using the bottom and left properties fixes the bottom-left corner; the width
+ * then extends to the right, while the height extends to the top. As an
+ * alternative to the four corners, a bar can be positioned exclusively using
+ * margins; this is convenient as an inset from the containing panel, for
+ * example. See {@link pv.Mark} for details on the prioritization of redundant
+ * positioning properties.
+ *
+ * <p>See also the <a href="../../api/Bar.html">Bar guide</a>.
+ *
+ * @extends pv.Mark
+ */
+pv.Bar = function() {
+  pv.Mark.call(this);
+};
+
+pv.Bar.prototype = pv.extend(pv.Mark)
+    .property("width", Number)
+    .property("height", Number)
+    .property("lineWidth", Number)
+    .property("strokeStyle", pv.color)
+    .property("fillStyle", pv.color);
+
+pv.Bar.prototype.type = "bar";
+
+/**
+ * The width of the bar, in pixels. If the left position is specified, the bar
+ * extends rightward from the left edge; if the right position is specified, the
+ * bar extends leftward from the right edge.
+ *
+ * @type number
+ * @name pv.Bar.prototype.width
+ */
+
+/**
+ * The height of the bar, in pixels. If the bottom position is specified, the
+ * bar extends upward from the bottom edge; if the top position is specified,
+ * the bar extends downward from the top edge.
+ *
+ * @type number
+ * @name pv.Bar.prototype.height
+ */
+
+/**
+ * The width of stroked lines, in pixels; used in conjunction with
+ * <tt>strokeStyle</tt> to stroke the bar's border.
+ *
+ * @type number
+ * @name pv.Bar.prototype.lineWidth
+ */
+
+/**
+ * The style of stroked lines; used in conjunction with <tt>lineWidth</tt> to
+ * stroke the bar's border. The default value of this property is null, meaning
+ * bars are not stroked by default.
+ *
+ * @type string
+ * @name pv.Bar.prototype.strokeStyle
+ * @see pv.color
+ */
+
+/**
+ * The bar fill style; if non-null, the interior of the bar is filled with the
+ * specified color. The default value of this property is a categorical color.
+ *
+ * @type string
+ * @name pv.Bar.prototype.fillStyle
+ * @see pv.color
+ */
+
+/**
+ * Default properties for bars. By default, there is no stroke and the fill
+ * style is a categorical color.
+ *
+ * @type pv.Bar
+ */
+pv.Bar.prototype.defaults = new pv.Bar()
+    .extend(pv.Mark.prototype.defaults)
+    .lineWidth(1.5)
+    .fillStyle(pv.Colors.category20().by(pv.parent));
diff --git a/vendor/protovis/src/mark/Dot.js b/vendor/protovis/src/mark/Dot.js
new file mode 100644
index 0000000..085d5f5
--- /dev/null
+++ b/vendor/protovis/src/mark/Dot.js
@@ -0,0 +1,212 @@
+/**
+ * Constructs a new dot mark with default properties. Dots are not typically
+ * constructed directly, but by adding to a panel or an existing mark via
+ * {@link pv.Mark#add}.
+ *
+ * @class Represents a dot; a dot is simply a sized glyph centered at a given
+ * point that can also be stroked and filled. The <tt>size</tt> property is
+ * proportional to the area of the rendered glyph to encourage meaningful visual
+ * encodings. Dots can visually encode up to eight dimensions of data, though
+ * this may be unwise due to integrality. See {@link pv.Mark} for details on the
+ * prioritization of redundant positioning properties.
+ *
+ * <p>See also the <a href="../../api/Dot.html">Dot guide</a>.
+ *
+ * @extends pv.Mark
+ */
+pv.Dot = function() {
+  pv.Mark.call(this);
+};
+
+pv.Dot.prototype = pv.extend(pv.Mark)
+    .property("shape", String)
+    .property("shapeAngle", Number)
+    .property("shapeRadius", Number)
+    .property("shapeSize", Number)
+    .property("lineWidth", Number)
+    .property("strokeStyle", pv.color)
+    .property("fillStyle", pv.color);
+
+pv.Dot.prototype.type = "dot";
+
+/**
+ * The size of the shape, in square pixels. Square pixels are used such that the
+ * area of the shape is linearly proportional to the value of the
+ * <tt>shapeSize</tt> property, facilitating representative encodings. This is
+ * an alternative to using {@link #shapeRadius}.
+ *
+ * @see #shapeRadius
+ * @type number
+ * @name pv.Dot.prototype.shapeSize
+ */
+
+/**
+ * The radius of the shape, in pixels. This is an alternative to using
+ * {@link #shapeSize}.
+ *
+ * @see #shapeSize
+ * @type number
+ * @name pv.Dot.prototype.shapeRadius
+ */
+
+/**
+ * The shape name. Several shapes are supported:<ul>
+ *
+ * <li>cross
+ * <li>triangle
+ * <li>diamond
+ * <li>square
+ * <li>circle
+ * <li>tick
+ * <li>bar
+ *
+ * </ul>These shapes can be further changed using the {@link #angle} property;
+ * for instance, a cross can be turned into a plus by rotating. Similarly, the
+ * tick, which is vertical by default, can be rotated horizontally. Note that
+ * some shapes (cross and tick) do not have interior areas, and thus do not
+ * support fill style meaningfully.
+ *
+ * <p>Note: it may be more natural to use the {@link pv.Rule} mark for
+ * horizontal and vertical ticks. The tick shape is only necessary if angled
+ * ticks are needed.
+ *
+ * @type string
+ * @name pv.Dot.prototype.shape
+ */
+
+/**
+ * The shape rotation angle, in radians. Used to rotate shapes, such as to turn
+ * a cross into a plus.
+ *
+ * @type number
+ * @name pv.Dot.prototype.shapeAngle
+ */
+
+/**
+ * The width of stroked lines, in pixels; used in conjunction with
+ * <tt>strokeStyle</tt> to stroke the dot's shape.
+ *
+ * @type number
+ * @name pv.Dot.prototype.lineWidth
+ */
+
+/**
+ * The style of stroked lines; used in conjunction with <tt>lineWidth</tt> to
+ * stroke the dot's shape. The default value of this property is a categorical
+ * color.
+ *
+ * @type string
+ * @name pv.Dot.prototype.strokeStyle
+ * @see pv.color
+ */
+
+/**
+ * The fill style; if non-null, the interior of the dot is filled with the
+ * specified color. The default value of this property is null, meaning dots are
+ * not filled by default.
+ *
+ * @type string
+ * @name pv.Dot.prototype.fillStyle
+ * @see pv.color
+ */
+
+/**
+ * Default properties for dots. By default, there is no fill and the stroke
+ * style is a categorical color. The default shape is "circle" with radius 4.5.
+ *
+ * @type pv.Dot
+ */
+pv.Dot.prototype.defaults = new pv.Dot()
+    .extend(pv.Mark.prototype.defaults)
+    .shape("circle")
+    .lineWidth(1.5)
+    .strokeStyle(pv.Colors.category10().by(pv.parent));
+
+/**
+ * Constructs a new dot anchor with default properties. Dots support five
+ * different anchors:<ul>
+ *
+ * <li>top
+ * <li>left
+ * <li>center
+ * <li>bottom
+ * <li>right
+ *
+ * </ul>In addition to positioning properties (left, right, top bottom), the
+ * anchors support text rendering properties (text-align, text-baseline). Text is
+ * rendered to appear outside the dot. Note that this behavior is different from
+ * other mark anchors, which default to rendering text <i>inside</i> the mark.
+ *
+ * <p>For consistency with the other mark types, the anchor positions are
+ * defined in terms of their opposite edge. For example, the top anchor defines
+ * the bottom property, such that a bar added to the top anchor grows upward.
+ *
+ * @param {string} name the anchor name; either a string or a property function.
+ * @returns {pv.Anchor}
+ */
+pv.Dot.prototype.anchor = function(name) {
+  var scene;
+  return pv.Mark.prototype.anchor.call(this, name)
+    .left(function() {
+        var s = this.scene.target[this.index];
+        switch (this.name()) {
+          case "bottom":
+          case "top":
+          case "center": return s.left;
+          case "left": return null;
+        }
+        return s.left + s.shapeRadius;
+      })
+    .right(function() {
+        var s = this.scene.target[this.index];
+        return this.name() == "left" ? s.right + s.shapeRadius : null;
+      })
+    .top(function() {
+        var s = this.scene.target[this.index];
+        switch (this.name()) {
+          case "left":
+          case "right":
+          case "center": return s.top;
+          case "top": return null;
+        }
+        return s.top + s.shapeRadius;
+      })
+    .bottom(function() {
+        var s = this.scene.target[this.index];
+        return this.name() == "top" ? s.bottom + s.shapeRadius : null;
+      })
+    .textAlign(function() {
+        switch (this.name()) {
+          case "left": return "right";
+          case "bottom":
+          case "top":
+          case "center": return "center";
+        }
+        return "left";
+      })
+    .textBaseline(function() {
+        switch (this.name()) {
+          case "right":
+          case "left":
+          case "center": return "middle";
+          case "bottom": return "top";
+        }
+        return "bottom";
+      });
+};
+
+/** @private Sets radius based on size or vice versa. */
+pv.Dot.prototype.buildImplied = function(s) {
+  var r = s.shapeRadius, z = s.shapeSize;
+  if (r == null) {
+    if (z == null) {
+      s.shapeSize = 20.25;
+      s.shapeRadius = 4.5;
+    } else {
+      s.shapeRadius = Math.sqrt(z);
+    }
+  } else if (z == null) {
+    s.shapeSize = r * r;
+  }
+  pv.Mark.prototype.buildImplied.call(this, s);
+};
diff --git a/vendor/protovis/src/mark/Ease.js b/vendor/protovis/src/mark/Ease.js
new file mode 100644
index 0000000..ea67032
--- /dev/null
+++ b/vendor/protovis/src/mark/Ease.js
@@ -0,0 +1,150 @@
+/*
+ * TERMS OF USE - EASING EQUATIONS
+ *
+ * Open source under the BSD License.
+ *
+ * Copyright 2001 Robert Penner
+ * 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 the author nor the names of 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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
+ */
+
+pv.Ease = (function() {
+
+  function reverse(f) {
+    return function(t) {
+      return 1 - f(1 - t);
+    };
+  }
+
+  function reflect(f) {
+    return function(t) {
+      return .5 * (t < .5 ? f(2 * t) : (2 - f(2 - 2 * t)));
+    };
+  }
+
+  function poly(e) {
+    return function(t) {
+      return t < 0 ? 0 : t > 1 ? 1 : Math.pow(t, e);
+    }
+  }
+
+  function sin(t) {
+    return 1 - Math.cos(t * Math.PI / 2);
+  }
+
+  function exp(t) {
+    return t ? Math.pow(2, 10 * (t - 1)) - 0.001 : 0;
+  }
+
+  function circle(t) {
+    return -(Math.sqrt(1 - t * t) - 1);
+  }
+
+  function elastic(a, p) {
+    var s;
+    if (!p) p = 0.45;
+    if (!a || a < 1) { a = 1; s = p / 4; }
+    else s = p / (2 * Math.PI) * Math.asin(1 / a);
+    return function(t) {
+      return t <= 0 || t >= 1 ? t
+          : -(a * Math.pow(2, 10 * (--t)) * Math.sin((t - s) * (2 * Math.PI) / p));
+    };
+  }
+
+  function back(s) {
+    if (!s) s = 1.70158;
+    return function(t) {
+      return t * t * ((s + 1) * t - s);
+    };
+  }
+
+  function bounce(t) {
+    return t < 1 / 2.75 ? 7.5625 * t * t
+        : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75
+        : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375
+        : 7.5625 * (t -= 2.625 / 2.75) * t + .984375;
+  }
+
+  var quad = poly(2),
+      cubic = poly(3),
+      elasticDefault = elastic(),
+      backDefault = back();
+
+  var eases = {
+    "linear": pv.identity,
+    "quad-in": quad,
+    "quad-out": reverse(quad),
+    "quad-in-out": reflect(quad),
+    "quad-out-in": reflect(reverse(quad)),
+    "cubic-in": cubic,
+    "cubic-out": reverse(cubic),
+    "cubic-in-out": reflect(cubic),
+    "cubic-out-in": reflect(reverse(cubic)),
+    "sin-in": sin,
+    "sin-out": reverse(sin),
+    "sin-in-out": reflect(sin),
+    "sin-out-in": reflect(reverse(sin)),
+    "exp-in": exp,
+    "exp-out": reverse(exp),
+    "exp-in-out": reflect(exp),
+    "exp-out-in": reflect(reverse(exp)),
+    "circle-in": circle,
+    "circle-out": reverse(circle),
+    "circle-in-out": reflect(circle),
+    "circle-out-in": reflect(reverse(circle)),
+    "elastic-in": elasticDefault,
+    "elastic-out": reverse(elasticDefault),
+    "elastic-in-out": reflect(elasticDefault),
+    "elastic-out-in": reflect(reverse(elasticDefault)),
+    "back-in": backDefault,
+    "back-out": reverse(backDefault),
+    "back-in-out": reflect(backDefault),
+    "back-out-in": reflect(reverse(backDefault)),
+    "bounce-in": bounce,
+    "bounce-out": reverse(bounce),
+    "bounce-in-out": reflect(bounce),
+    "bounce-out-in": reflect(reverse(bounce))
+  };
+
+  pv.ease = function(f) {
+    return eases[f];
+  };
+
+  return {
+    reverse: reverse,
+    reflect: reflect,
+    linear: function() { return pv.identity; },
+    sin: function() { return sin; },
+    exp: function() { return exp; },
+    circle: function() { return circle; },
+    elastic: elastic,
+    back: back,
+    bounce: bounce,
+    poly: poly
+  };
+})();
diff --git a/vendor/protovis/src/mark/Image.js b/vendor/protovis/src/mark/Image.js
new file mode 100644
index 0000000..130b8b9
--- /dev/null
+++ b/vendor/protovis/src/mark/Image.js
@@ -0,0 +1,154 @@
+/**
+ * Constructs a new image with default properties. Images are not typically
+ * constructed directly, but by adding to a panel or an existing mark via
+ * {@link pv.Mark#add}.
+ *
+ * @class Represents an image, either a static resource or a dynamically-
+ * generated pixel buffer. Images share the same layout and style properties as
+ * bars. The external image resource is specified via the {@link #url}
+ * property. The optional fill, if specified, appears beneath the image, while
+ * the optional stroke appears above the image.
+ *
+ * <p>Dynamic images such as heatmaps are supported using the {@link #image}
+ * psuedo-property. This function is passed the <i>x</i> and <i>y</i> index, in
+ * addition to the current data stack. The return value is a {@link pv.Color},
+ * or null for transparent. A string can also be returned, which will be parsed
+ * into a color; however, it is typically much faster to return an object with
+ * <tt>r</tt>, <tt>g</tt>, <tt>b</tt> and <tt>a</tt> attributes, to avoid the
+ * cost of parsing and object instantiation.
+ *
+ * <p>See {@link pv.Bar} for details on positioning properties.
+ *
+ * @extends pv.Bar
+ */
+pv.Image = function() {
+  pv.Bar.call(this);
+};
+
+pv.Image.prototype = pv.extend(pv.Bar)
+    .property("url", String)
+    .property("imageWidth", Number)
+    .property("imageHeight", Number);
+
+pv.Image.prototype.type = "image";
+
+/**
+ * The URL of the image to display. The set of supported image types is
+ * browser-dependent; PNG and JPEG are recommended.
+ *
+ * @type string
+ * @name pv.Image.prototype.url
+ */
+
+/**
+ * The width of the image in pixels. For static images, this property is
+ * computed implicitly from the loaded image resources. For dynamic images, this
+ * property can be used to specify the width of the pixel buffer; otherwise, the
+ * value is derived from the <tt>width</tt> property.
+ *
+ * @type number
+ * @name pv.Image.prototype.imageWidth
+ */
+
+/**
+ * The height of the image in pixels. For static images, this property is
+ * computed implicitly from the loaded image resources. For dynamic images, this
+ * property can be used to specify the height of the pixel buffer; otherwise, the
+ * value is derived from the <tt>height</tt> property.
+ *
+ * @type number
+ * @name pv.Image.prototype.imageHeight
+ */
+
+/**
+ * Default properties for images. By default, there is no stroke or fill style.
+ *
+ * @type pv.Image
+ */
+pv.Image.prototype.defaults = new pv.Image()
+    .extend(pv.Bar.prototype.defaults)
+    .fillStyle(null);
+
+/**
+ * Specifies the dynamic image function. By default, no image function is
+ * specified and the <tt>url</tt> property is used to load a static image
+ * resource. If an image function is specified, it will be invoked for each
+ * pixel in the image, based on the related <tt>imageWidth</tt> and
+ * <tt>imageHeight</tt> properties.
+ *
+ * <p>For example, given a two-dimensional array <tt>heatmap</tt>, containing
+ * numbers in the range [0, 1] in row-major order, a simple monochrome heatmap
+ * image can be specified as:
+ *
+ * <pre>vis.add(pv.Image)
+ *     .imageWidth(heatmap[0].length)
+ *     .imageHeight(heatmap.length)
+ *     .image(pv.ramp("white", "black").by(function(x, y) heatmap[y][x]));</pre>
+ *
+ * For fastest performance, use an ordinal scale which caches the fixed color
+ * palette, or return an object literal with <tt>r</tt>, <tt>g</tt>, <tt>b</tt>
+ * and <tt>a</tt> attributes. A {@link pv.Color} or string can also be returned,
+ * though this typically results in slower performance.
+ *
+ * @param {function} f the new sizing function.
+ * @returns {pv.Layout.Pack} this.
+ */
+pv.Image.prototype.image = function(f) {
+  /** @private */
+  this.$image = function() {
+      var c = f.apply(this, arguments);
+      return c == null ? pv.Color.transparent
+          : typeof c == "string" ? pv.color(c)
+          : c;
+    };
+  return this;
+};
+
+/** @private Scan the proto chain for an image function. */
+pv.Image.prototype.bind = function() {
+  pv.Bar.prototype.bind.call(this);
+  var binds = this.binds, mark = this;
+  do {
+    binds.image = mark.$image;
+  } while (!binds.image && (mark = mark.proto));
+};
+
+/** @private */
+pv.Image.prototype.buildImplied = function(s) {
+  pv.Bar.prototype.buildImplied.call(this, s);
+  if (!s.visible) return;
+
+  /* Compute the implied image dimensions. */
+  if (s.imageWidth == null) s.imageWidth = s.width;
+  if (s.imageHeight == null) s.imageHeight = s.height;
+
+  /* Compute the pixel values. */
+  if ((s.url == null) && this.binds.image) {
+
+    /* Cache the canvas element to reuse across renders. */
+    var canvas = this.$canvas || (this.$canvas = document.createElement("canvas")),
+        context = canvas.getContext("2d"),
+        w = s.imageWidth,
+        h = s.imageHeight,
+        stack = pv.Mark.stack,
+        data;
+
+    /* Evaluate the image function, storing into a CanvasPixelArray. */
+    canvas.width = w;
+    canvas.height = h;
+    data = (s.image = context.createImageData(w, h)).data;
+    stack.unshift(null, null);
+    for (var y = 0, p = 0; y < h; y++) {
+      stack[1] = y;
+      for (var x = 0; x < w; x++) {
+        stack[0] = x;
+        var color = this.binds.image.apply(this, stack);
+        data[p++] = color.r;
+        data[p++] = color.g;
+        data[p++] = color.b;
+        data[p++] = 255 * color.a;
+      }
+    }
+    stack.splice(0, 2);
+  }
+};
diff --git a/vendor/protovis/src/mark/Label.js b/vendor/protovis/src/mark/Label.js
new file mode 100644
index 0000000..56c1851
--- /dev/null
+++ b/vendor/protovis/src/mark/Label.js
@@ -0,0 +1,155 @@
+/**
+ * Constructs a new label mark with default properties. Labels are not typically
+ * constructed directly, but by adding to a panel or an existing mark via
+ * {@link pv.Mark#add}.
+ *
+ * @class Represents a text label, allowing textual annotation of other marks or
+ * arbitrary text within the visualization. The character data must be plain
+ * text (unicode), though the text can be styled using the {@link #font}
+ * property. If rich text is needed, external HTML elements can be overlaid on
+ * the canvas by hand.
+ *
+ * <p>Labels are positioned using the box model, similarly to {@link Dot}. Thus,
+ * a label has no width or height, but merely a text anchor location. The text
+ * is positioned relative to this anchor location based on the
+ * {@link #textAlign}, {@link #textBaseline} and {@link #textMargin} properties.
+ * Furthermore, the text may be rotated using {@link #textAngle}.
+ *
+ * <p>Labels ignore events, so as to not interfere with event handlers on
+ * underlying marks, such as bars. In the future, we may support event handlers
+ * on labels.
+ *
+ * <p>See also the <a href="../../api/Label.html">Label guide</a>.
+ *
+ * @extends pv.Mark
+ */
+pv.Label = function() {
+  pv.Mark.call(this);
+};
+
+pv.Label.prototype = pv.extend(pv.Mark)
+    .property("text", String)
+    .property("font", String)
+    .property("textAngle", Number)
+    .property("textStyle", pv.color)
+    .property("textAlign", String)
+    .property("textBaseline", String)
+    .property("textMargin", Number)
+    .property("textDecoration", String)
+    .property("textShadow", String);
+
+pv.Label.prototype.type = "label";
+
+/**
+ * The character data to render; a string. The default value of the text
+ * property is the identity function, meaning the label's associated datum will
+ * be rendered using its <tt>toString</tt>.
+ *
+ * @type string
+ * @name pv.Label.prototype.text
+ */
+
+/**
+ * The font format, per the CSS Level 2 specification. The default font is "10px
+ * sans-serif", for consistency with the HTML 5 canvas element specification.
+ * Note that since text is not wrapped, any line-height property will be
+ * ignored. The other font-style, font-variant, font-weight, font-size and
+ * font-family properties are supported.
+ *
+ * @see <a href="http://www.w3.org/TR/CSS2/fonts.html#font-shorthand">CSS2 fonts</a>
+ * @type string
+ * @name pv.Label.prototype.font
+ */
+
+/**
+ * The rotation angle, in radians. Text is rotated clockwise relative to the
+ * anchor location. For example, with the default left alignment, an angle of
+ * Math.PI / 2 causes text to proceed downwards. The default angle is zero.
+ *
+ * @type number
+ * @name pv.Label.prototype.textAngle
+ */
+
+/**
+ * The text color. The name "textStyle" is used for consistency with "fillStyle"
+ * and "strokeStyle", although it might be better to rename this property (and
+ * perhaps use the same name as "strokeStyle"). The default color is black.
+ *
+ * @type string
+ * @name pv.Label.prototype.textStyle
+ * @see pv.color
+ */
+
+/**
+ * The horizontal text alignment. One of:<ul>
+ *
+ * <li>left
+ * <li>center
+ * <li>right
+ *
+ * </ul>The default horizontal alignment is left.
+ *
+ * @type string
+ * @name pv.Label.prototype.textAlign
+ */
+
+/**
+ * The vertical text alignment. One of:<ul>
+ *
+ * <li>top
+ * <li>middle
+ * <li>bottom
+ *
+ * </ul>The default vertical alignment is bottom.
+ *
+ * @type string
+ * @name pv.Label.prototype.textBaseline
+ */
+
+/**
+ * The text margin; may be specified in pixels, or in font-dependent units (such
+ * as ".1ex"). The margin can be used to pad text away from its anchor location,
+ * in a direction dependent on the horizontal and vertical alignment
+ * properties. For example, if the text is left- and middle-aligned, the margin
+ * shifts the text to the right. The default margin is 3 pixels.
+ *
+ * @type number
+ * @name pv.Label.prototype.textMargin
+ */
+
+/**
+ * A list of shadow effects to be applied to text, per the CSS Text Level 3
+ * text-shadow property. An example specification is "0.1em 0.1em 0.1em
+ * rgba(0,0,0,.5)"; the first length is the horizontal offset, the second the
+ * vertical offset, and the third the blur radius.
+ *
+ * @see <a href="http://www.w3.org/TR/css3-text/#text-shadow">CSS3 text</a>
+ * @type string
+ * @name pv.Label.prototype.textShadow
+ */
+
+/**
+ * A list of decoration to be applied to text, per the CSS Text Level 3
+ * text-decoration property. An example specification is "underline".
+ *
+ * @see <a href="http://www.w3.org/TR/css3-text/#text-decoration">CSS3 text</a>
+ * @type string
+ * @name pv.Label.prototype.textDecoration
+ */
+
+/**
+ * Default properties for labels. See the individual properties for the default
+ * values.
+ *
+ * @type pv.Label
+ */
+pv.Label.prototype.defaults = new pv.Label()
+    .extend(pv.Mark.prototype.defaults)
+    .events("none")
+    .text(pv.identity)
+    .font("10px sans-serif")
+    .textAngle(0)
+    .textStyle("black")
+    .textAlign("left")
+    .textBaseline("bottom")
+    .textMargin(3);
diff --git a/vendor/protovis/src/mark/Line.js b/vendor/protovis/src/mark/Line.js
new file mode 100644
index 0000000..1b26566
--- /dev/null
+++ b/vendor/protovis/src/mark/Line.js
@@ -0,0 +1,195 @@
+/**
+ * Constructs a new line mark with default properties. Lines are not typically
+ * constructed directly, but by adding to a panel or an existing mark via
+ * {@link pv.Mark#add}.
+ *
+ * @class Represents a series of connected line segments, or <i>polyline</i>,
+ * that can be stroked with a configurable color and thickness. Each
+ * articulation point in the line corresponds to a datum; for <i>n</i> points,
+ * <i>n</i>-1 connected line segments are drawn. The point is positioned using
+ * the box model. Arbitrary paths are also possible, allowing radar plots and
+ * other custom visualizations.
+ *
+ * <p>Like areas, lines can be stroked and filled with arbitrary colors. In most
+ * cases, lines are only stroked, but the fill style can be used to construct
+ * arbitrary polygons.
+ *
+ * <p>See also the <a href="../../api/Line.html">Line guide</a>.
+ *
+ * @extends pv.Mark
+ */
+pv.Line = function() {
+  pv.Mark.call(this);
+};
+
+pv.Line.prototype = pv.extend(pv.Mark)
+    .property("lineWidth", Number)
+    .property("lineJoin", String)
+    .property("strokeStyle", pv.color)
+    .property("fillStyle", pv.color)
+    .property("segmented", Boolean)
+    .property("interpolate", String)
+    .property("eccentricity", Number)
+    .property("tension", Number);
+
+pv.Line.prototype.type = "line";
+
+/**
+ * The width of stroked lines, in pixels; used in conjunction with
+ * <tt>strokeStyle</tt> to stroke the line.
+ *
+ * @type number
+ * @name pv.Line.prototype.lineWidth
+ */
+
+/**
+ * The style of stroked lines; used in conjunction with <tt>lineWidth</tt> to
+ * stroke the line. The default value of this property is a categorical color.
+ *
+ * @type string
+ * @name pv.Line.prototype.strokeStyle
+ * @see pv.color
+ */
+
+/**
+ * The type of corners where two lines meet. Accepted values are "bevel",
+ * "round" and "miter". The default value is "miter".
+ *
+ * <p>For segmented lines, only "miter" joins and "linear" interpolation are
+ * currently supported. Any other value, including null, will disable joins,
+ * producing disjoint line segments. Note that the miter joins must be computed
+ * manually (at least in the current SVG renderer); since this calculation may
+ * be expensive and unnecessary for small lines, specifying null can improve
+ * performance significantly.
+ *
+ * <p>This property is <i>fixed</i>. See {@link pv.Mark}.
+ *
+ * @type string
+ * @name pv.Line.prototype.lineJoin
+ */
+
+/**
+ * The line fill style; if non-null, the interior of the line is closed and
+ * filled with the specified color. The default value of this property is a
+ * null, meaning that lines are not filled by default.
+ *
+ * <p>This property is <i>fixed</i>. See {@link pv.Mark}.
+ *
+ * @type string
+ * @name pv.Line.prototype.fillStyle
+ * @see pv.color
+ */
+
+/**
+ * Whether the line is segmented; whether variations in stroke style, line width
+ * and the other properties are treated as fixed. Rendering segmented lines is
+ * noticeably slower than non-segmented lines.
+ *
+ * <p>This property is <i>fixed</i>. See {@link pv.Mark}.
+ *
+ * @type boolean
+ * @name pv.Line.prototype.segmented
+ */
+
+/**
+ * How to interpolate between values. Linear interpolation ("linear") is the
+ * default, producing a straight line between points. For piecewise constant
+ * functions (i.e., step functions), either "step-before" or "step-after" can be
+ * specified. To draw a clockwise circular arc between points, specify "polar";
+ * to draw a counterclockwise circular arc between points, specify
+ * "polar-reverse". To draw open uniform b-splines, specify "basis". To draw
+ * cardinal splines, specify "cardinal"; see also {@link #tension}.
+ *
+ * <p>This property is <i>fixed</i>. See {@link pv.Mark}.
+ *
+ * @type string
+ * @name pv.Line.prototype.interpolate
+ */
+
+/**
+ * The eccentricity of polar line segments; used in conjunction with
+ * interpolate("polar"). The default value of 0 means that line segments are
+ * drawn as circular arcs. A value of 1 draws a straight line. A value between 0
+ * and 1 draws an elliptical arc with the given eccentricity.
+ *
+ * @type number
+ * @name pv.Line.prototype.eccentricity
+ */
+
+/**
+ * The tension of cardinal splines; used in conjunction with
+ * interpolate("cardinal"). A value between 0 and 1 draws cardinal splines with
+ * the given tension. In some sense, the tension can be interpreted as the
+ * "length" of the tangent; a tension of 1 will yield all zero tangents (i.e.,
+ * linear interpolation), and a tension of 0 yields a Catmull-Rom spline. The
+ * default value is 0.7.
+ *
+ * <p>This property is <i>fixed</i>. See {@link pv.Mark}.
+ *
+ * @type number
+ * @name pv.Line.prototype.tension
+ */
+
+/**
+ * Default properties for lines. By default, there is no fill and the stroke
+ * style is a categorical color. The default interpolation is linear.
+ *
+ * @type pv.Line
+ */
+pv.Line.prototype.defaults = new pv.Line()
+    .extend(pv.Mark.prototype.defaults)
+    .lineJoin("miter")
+    .lineWidth(1.5)
+    .strokeStyle(pv.Colors.category10().by(pv.parent))
+    .interpolate("linear")
+    .eccentricity(0)
+    .tension(.7);
+
+/** @private Reuse Area's implementation for segmented bind & build. */
+pv.Line.prototype.bind = pv.Area.prototype.bind;
+pv.Line.prototype.buildInstance = pv.Area.prototype.buildInstance;
+
+/**
+ * Constructs a new line anchor with default properties. Lines support five
+ * different anchors:<ul>
+ *
+ * <li>top
+ * <li>left
+ * <li>center
+ * <li>bottom
+ * <li>right
+ *
+ * </ul>In addition to positioning properties (left, right, top bottom), the
+ * anchors support text rendering properties (text-align, text-baseline). Text is
+ * rendered to appear outside the line. Note that this behavior is different
+ * from other mark anchors, which default to rendering text <i>inside</i> the
+ * mark.
+ *
+ * <p>For consistency with the other mark types, the anchor positions are
+ * defined in terms of their opposite edge. For example, the top anchor defines
+ * the bottom property, such that a bar added to the top anchor grows upward.
+ *
+ * @param {string} name the anchor name; either a string or a property function.
+ * @returns {pv.Anchor}
+ */
+pv.Line.prototype.anchor = function(name) {
+  return pv.Area.prototype.anchor.call(this, name)
+    .textAlign(function(d) {
+        switch (this.name()) {
+          case "left": return "right";
+          case "bottom":
+          case "top":
+          case "center": return "center";
+          case "right": return "left";
+        }
+      })
+    .textBaseline(function(d) {
+        switch (this.name()) {
+          case "right":
+          case "left":
+          case "center": return "middle";
+          case "top": return "bottom";
+          case "bottom": return "top";
+        }
+      });
+};
diff --git a/vendor/protovis/src/mark/Mark.js b/vendor/protovis/src/mark/Mark.js
new file mode 100644
index 0000000..12491f9
--- /dev/null
+++ b/vendor/protovis/src/mark/Mark.js
@@ -0,0 +1,1237 @@
+/**
+ * Constructs a new mark with default properties. Marks, with the exception of
+ * the root panel, are not typically constructed directly; instead, they are
+ * added to a panel or an existing mark via {@link pv.Mark#add}.
+ *
+ * @class Represents a data-driven graphical mark. The <tt>Mark</tt> class is
+ * the base class for all graphical marks in Protovis; it does not provide any
+ * specific rendering functionality, but together with {@link Panel} establishes
+ * the core framework.
+ *
+ * <p>Concrete mark types include familiar visual elements such as bars, lines
+ * and labels. Although a bar mark may be used to construct a bar chart, marks
+ * know nothing about charts; it is only through their specification and
+ * composition that charts are produced. These building blocks permit many
+ * combinatorial possibilities.
+ *
+ * <p>Marks are associated with <b>data</b>: a mark is generated once per
+ * associated datum, mapping the datum to visual <b>properties</b> such as
+ * position and color. Thus, a single mark specification represents a set of
+ * visual elements that share the same data and visual encoding. The type of
+ * mark defines the names of properties and their meaning. A property may be
+ * static, ignoring the associated datum and returning a constant; or, it may be
+ * dynamic, derived from the associated datum or index. Such dynamic encodings
+ * can be specified succinctly using anonymous functions. Special properties
+ * called event handlers can be registered to add interactivity.
+ *
+ * <p>Protovis uses <b>inheritance</b> to simplify the specification of related
+ * marks: a new mark can be derived from an existing mark, inheriting its
+ * properties. The new mark can then override properties to specify new
+ * behavior, potentially in terms of the old behavior. In this way, the old mark
+ * serves as the <b>prototype</b> for the new mark. Most mark types share the
+ * same basic properties for consistency and to facilitate inheritance.
+ *
+ * <p>The prioritization of redundant properties is as follows:<ol>
+ *
+ * <li>If the <tt>width</tt> property is not specified (i.e., null), its value
+ * is the width of the parent panel, minus this mark's left and right margins;
+ * the left and right margins are zero if not specified.
+ *
+ * <li>Otherwise, if the <tt>right</tt> margin is not specified, its value is
+ * the width of the parent panel, minus this mark's width and left margin; the
+ * left margin is zero if not specified.
+ *
+ * <li>Otherwise, if the <tt>left</tt> property is not specified, its value is
+ * the width of the parent panel, minus this mark's width and the right margin.
+ *
+ * </ol>This prioritization is then duplicated for the <tt>height</tt>,
+ * <tt>bottom</tt> and <tt>top</tt> properties, respectively.
+ *
+ * <p>While most properties are <i>variable</i>, some mark types, such as lines
+ * and areas, generate a single visual element rather than a distinct visual
+ * element per datum. With these marks, some properties may be <b>fixed</b>.
+ * Fixed properties can vary per mark, but not <i>per datum</i>! These
+ * properties are evaluated solely for the first (0-index) datum, and typically
+ * are specified as a constant. However, it is valid to use a function if the
+ * property varies between panels or is dynamically generated.
+ *
+ * <p>See also the <a href="../../api/">Protovis guide</a>.
+ */
+pv.Mark = function() {
+  /*
+   * TYPE 0 constant defs
+   * TYPE 1 function defs
+   * TYPE 2 constant properties
+   * TYPE 3 function properties
+   * in order of evaluation!
+   */
+  this.$properties = [];
+  this.$handlers = {};
+};
+
+/** @private Records which properties are defined on this mark type. */
+pv.Mark.prototype.properties = {};
+
+/** @private Records the cast function for each property. */
+pv.Mark.cast = {};
+
+/**
+ * @private Defines and registers a property method for the property with the
+ * given name.  This method should be called on a mark class prototype to define
+ * each exposed property. (Note this refers to the JavaScript
+ * <tt>prototype</tt>, not the Protovis mark prototype, which is the {@link
+ * #proto} field.)
+ *
+ * <p>The created property method supports several modes of invocation: <ol>
+ *
+ * <li>If invoked with a <tt>Function</tt> argument, this function is evaluated
+ * for each associated datum. The return value of the function is used as the
+ * computed property value. The context of the function (<tt>this</tt>) is this
+ * mark. The arguments to the function are the associated data of this mark and
+ * any enclosing panels. For example, a linear encoding of numerical data to
+ * height is specified as
+ *
+ * <pre>m.height(function(d) d * 100);</pre>
+ *
+ * The expression <tt>d * 100</tt> will be evaluated for the height property of
+ * each mark instance. The return value of the property method (e.g.,
+ * <tt>m.height</tt>) is this mark (<tt>m</tt>)).<p>
+ *
+ * <li>If invoked with a non-function argument, the property is treated as a
+ * constant. The return value of the property method (e.g., <tt>m.height</tt>)
+ * is this mark.<p>
+ *
+ * <li>If invoked with no arguments, the computed property value for the current
+ * mark instance in the scene graph is returned. This facilitates <i>property
+ * chaining</i>, where one mark's properties are defined in terms of another's.
+ * For example, to offset a mark's location from its prototype, you might say
+ *
+ * <pre>m.top(function() this.proto.top() + 10);</pre>
+ *
+ * Note that the index of the mark being evaluated (in the above example,
+ * <tt>this.proto</tt>) is inherited from the <tt>Mark</tt> class and set by
+ * this mark. So, if the fifth element's top property is being evaluated, the
+ * fifth instance of <tt>this.proto</tt> will similarly be queried for the value
+ * of its top property. If the mark being evaluated has a different number of
+ * instances, or its data is unrelated, the behavior of this method is
+ * undefined. In these cases it may be better to index the <tt>scene</tt>
+ * explicitly to specify the exact instance.
+ *
+ * </ol><p>Property names should follow standard JavaScript method naming
+ * conventions, using lowerCamel-style capitalization.
+ *
+ * <p>In addition to creating the property method, every property is registered
+ * in the {@link #properties} map on the <tt>prototype</tt>. Although this is an
+ * instance field, it is considered immutable and shared by all instances of a
+ * given mark type. The <tt>properties</tt> map can be queried to see if a mark
+ * type defines a particular property, such as width or height.
+ *
+ * @param {string} name the property name.
+ * @param {function} [cast] the cast function for this property.
+ */
+pv.Mark.prototype.property = function(name, cast) {
+  if (!this.hasOwnProperty("properties")) {
+    this.properties = pv.extend(this.properties);
+  }
+  this.properties[name] = true;
+
+  /*
+   * Define the setter-getter globally, since the default behavior should be the
+   * same for all properties, and since the Protovis inheritance chain is
+   * independent of the JavaScript inheritance chain. For example, anchors
+   * define a "name" property that is evaluated on derived marks, even though
+   * those marks don't normally have a name.
+   */
+  pv.Mark.prototype.propertyMethod(name, false, pv.Mark.cast[name] = cast);
+  return this;
+};
+
+/**
+ * @private Defines a setter-getter for the specified property.
+ *
+ * <p>If a cast function has been assigned to the specified property name, the
+ * property function is wrapped by the cast function, or, if a constant is
+ * specified, the constant is immediately cast. Note, however, that if the
+ * property value is null, the cast function is not invoked.
+ *
+ * @param {string} name the property name.
+ * @param {boolean} [def] whether is a property or a def.
+ * @param {function} [cast] the cast function for this property.
+ */
+pv.Mark.prototype.propertyMethod = function(name, def, cast) {
+  if (!cast) cast = pv.Mark.cast[name];
+  this[name] = function(v) {
+
+      /* If this is a def, use it rather than property. */
+      if (def && this.scene) {
+        var defs = this.scene.defs;
+        if (arguments.length) {
+          defs[name] = {
+            id: (v == null) ? 0 : pv.id(),
+            value: ((v != null) && cast) ? cast(v) : v
+          };
+          return this;
+        }
+        return defs[name] ? defs[name].value : null;
+      }
+
+      /* If arguments are specified, set the property value. */
+      if (arguments.length) {
+        var type = !def << 1 | (typeof v == "function");
+        this.propertyValue(name, (type & 1 && cast) ? function() {
+            var x = v.apply(this, arguments);
+            return (x != null) ? cast(x) : null;
+          } : (((v != null) && cast) ? cast(v) : v)).type = type;
+        return this;
+      }
+
+      return this.instance()[name];
+    };
+};
+
+/** @private Sets the value of the property <i>name</i> to <i>v</i>. */
+pv.Mark.prototype.propertyValue = function(name, v) {
+  var properties = this.$properties, p = {name: name, id: pv.id(), value: v};
+  for (var i = 0; i < properties.length; i++) {
+    if (properties[i].name == name) {
+      properties.splice(i, 1);
+      break;
+    }
+  }
+  properties.push(p);
+  return p;
+};
+
+/* Define all global properties. */
+pv.Mark.prototype
+    .property("data")
+    .property("visible", Boolean)
+    .property("left", Number)
+    .property("right", Number)
+    .property("top", Number)
+    .property("bottom", Number)
+    .property("cursor", String)
+    .property("title", String)
+    .property("reverse", Boolean)
+    .property("antialias", Boolean)
+    .property("events", String)
+    .property("id", String);
+
+/**
+ * The mark type; a lower camelCase name. The type name controls rendering
+ * behavior, and unless the rendering engine is extended, must be one of the
+ * built-in concrete mark types: area, bar, dot, image, label, line, panel,
+ * rule, or wedge.
+ *
+ * @type string
+ * @name pv.Mark.prototype.type
+ */
+
+/**
+ * The mark prototype, possibly undefined, from which to inherit property
+ * functions. The mark prototype is not necessarily of the same type as this
+ * mark. Any properties defined on this mark will override properties inherited
+ * either from the prototype or from the type-specific defaults.
+ *
+ * @type pv.Mark
+ * @name pv.Mark.prototype.proto
+ */
+
+/**
+ * The mark anchor target, possibly undefined.
+ *
+ * @type pv.Mark
+ * @name pv.Mark.prototype.target
+ */
+
+/**
+ * The enclosing parent panel. The parent panel is generally undefined only for
+ * the root panel; however, it is possible to create "offscreen" marks that are
+ * used only for inheritance purposes.
+ *
+ * @type pv.Panel
+ * @name pv.Mark.prototype.parent
+ */
+
+/**
+ * The child index. -1 if the enclosing parent panel is null; otherwise, the
+ * zero-based index of this mark into the parent panel's <tt>children</tt> array.
+ *
+ * @type number
+ */
+pv.Mark.prototype.childIndex = -1;
+
+/**
+ * The mark index. The value of this field depends on which instance (i.e.,
+ * which element of the data array) is currently being evaluated. During the
+ * build phase, the index is incremented over each datum; when handling events,
+ * the index is set to the instance that triggered the event.
+ *
+ * @type number
+ */
+pv.Mark.prototype.index = -1;
+
+/**
+ * The current scale factor, based on any enclosing transforms. The current
+ * scale can be used to create scale-independent graphics. For example, to
+ * define a dot that has a radius of 10 irrespective of any zooming, say:
+ *
+ * <pre>dot.shapeRadius(function() 10 / this.scale)</pre>
+ *
+ * Note that the stroke width and font size are defined irrespective of scale
+ * (i.e., in screen space) already. Also note that when a transform is applied
+ * to a panel, the scale affects only the child marks, not the panel itself.
+ *
+ * @type number
+ * @see pv.Panel#transform
+ */
+pv.Mark.prototype.scale = 1;
+
+/**
+ * @private The scene graph. The scene graph is an array of objects; each object
+ * (or "node") corresponds to an instance of this mark and an element in the
+ * data array. The scene graph can be traversed to lookup previously-evaluated
+ * properties.
+ *
+ * @name pv.Mark.prototype.scene
+ */
+
+/**
+ * The root parent panel. This may be undefined for "offscreen" marks that are
+ * created for inheritance purposes only.
+ *
+ * @type pv.Panel
+ * @name pv.Mark.prototype.root
+ */
+
+/**
+ * The data property; an array of objects. The size of the array determines the
+ * number of marks that will be instantiated; each element in the array will be
+ * passed to property functions to compute the property values. Typically, the
+ * data property is specified as a constant array, such as
+ *
+ * <pre>m.data([1, 2, 3, 4, 5]);</pre>
+ *
+ * However, it is perfectly acceptable to define the data property as a
+ * function. This function might compute the data dynamically, allowing
+ * different data to be used per enclosing panel. For instance, in the stacked
+ * area graph example (see {@link #scene}), the data function on the area mark
+ * dereferences each series.
+ *
+ * @type array
+ * @name pv.Mark.prototype.data
+ */
+
+/**
+ * The visible property; a boolean determining whether or not the mark instance
+ * is visible. If a mark instance is not visible, its other properties will not
+ * be evaluated. Similarly, for panels no child marks will be rendered.
+ *
+ * @type boolean
+ * @name pv.Mark.prototype.visible
+ */
+
+/**
+ * The left margin; the distance, in pixels, between the left edge of the
+ * enclosing panel and the left edge of this mark. Note that in some cases this
+ * property may be redundant with the right property, or with the conjunction of
+ * right and width.
+ *
+ * @type number
+ * @name pv.Mark.prototype.left
+ */
+
+/**
+ * The right margin; the distance, in pixels, between the right edge of the
+ * enclosing panel and the right edge of this mark. Note that in some cases this
+ * property may be redundant with the left property, or with the conjunction of
+ * left and width.
+ *
+ * @type number
+ * @name pv.Mark.prototype.right
+ */
+
+/**
+ * The top margin; the distance, in pixels, between the top edge of the
+ * enclosing panel and the top edge of this mark. Note that in some cases this
+ * property may be redundant with the bottom property, or with the conjunction
+ * of bottom and height.
+ *
+ * @type number
+ * @name pv.Mark.prototype.top
+ */
+
+/**
+ * The bottom margin; the distance, in pixels, between the bottom edge of the
+ * enclosing panel and the bottom edge of this mark. Note that in some cases
+ * this property may be redundant with the top property, or with the conjunction
+ * of top and height.
+ *
+ * @type number
+ * @name pv.Mark.prototype.bottom
+ */
+
+/**
+ * The cursor property; corresponds to the CSS cursor property. This is
+ * typically used in conjunction with event handlers to indicate interactivity.
+ *
+ * @type string
+ * @name pv.Mark.prototype.cursor
+ * @see <a href="http://www.w3.org/TR/CSS2/ui.html#propdef-cursor">CSS2 cursor</a>
+ */
+
+/**
+ * The title property; corresponds to the HTML/SVG title property, allowing the
+ * general of simple plain text tooltips.
+ *
+ * @type string
+ * @name pv.Mark.prototype.title
+ */
+
+/**
+ * The events property; corresponds to the SVG pointer-events property,
+ * specifying how the mark should participate in mouse events. The default value
+ * is "painted". Supported values are:
+ *
+ * <p>"painted": The given mark may receive events when the mouse is over a
+ * "painted" area. The painted areas are the interior (i.e., fill) of the mark
+ * if a 'fillStyle' is specified, and the perimeter (i.e., stroke) of the mark
+ * if a 'strokeStyle' is specified.
+ *
+ * <p>"all": The given mark may receive events when the mouse is over either the
+ * interior (i.e., fill) or the perimeter (i.e., stroke) of the mark, regardless
+ * of the specified fillStyle and strokeStyle.
+ *
+ * <p>"none": The given mark may not receive events.
+ *
+ * @type string
+ * @name pv.Mark.prototype.events
+ */
+
+/**
+ * The reverse property; a boolean determining whether marks are ordered from
+ * front-to-back or back-to-front. SVG does not support explicit z-ordering;
+ * shapes are rendered in the order they appear. Thus, by default, marks are
+ * rendered in data order. Setting the reverse property to false reverses the
+ * order in which they are rendered; however, the properties are still evaluated
+ * (i.e., built) in forward order.
+ *
+ * @type boolean
+ * @name pv.Mark.prototype.reverse
+ */
+
+/**
+ * The instance identifier, for correspondence across animated transitions. If
+ * no identifier is specified, correspondence is determined using the mark
+ * index. Identifiers are not global, but local to a given mark.
+ *
+ * @type String
+ * @name pv.Mark.prototype.id
+ */
+
+/**
+ * Default properties for all mark types. By default, the data array is the
+ * parent data as a single-element array; if the data property is not specified,
+ * this causes each mark to be instantiated as a singleton with the parents
+ * datum. The visible property is true by default, and the reverse property is
+ * false.
+ *
+ * @type pv.Mark
+ */
+pv.Mark.prototype.defaults = new pv.Mark()
+    .data(function(d) { return [d]; })
+    .visible(true)
+    .antialias(true)
+    .events("painted");
+
+/**
+ * Sets the prototype of this mark to the specified mark. Any properties not
+ * defined on this mark may be inherited from the specified prototype mark, or
+ * its prototype, and so on. The prototype mark need not be the same type of
+ * mark as this mark. (Note that for inheritance to be useful, properties with
+ * the same name on different mark types should have equivalent meaning.)
+ *
+ * @param {pv.Mark} proto the new prototype.
+ * @returns {pv.Mark} this mark.
+ * @see #add
+ */
+pv.Mark.prototype.extend = function(proto) {
+  this.proto = proto;
+  this.target = proto.target;
+  return this;
+};
+
+/**
+ * Adds a new mark of the specified type to the enclosing parent panel, whilst
+ * simultaneously setting the prototype of the new mark to be this mark.
+ *
+ * @param {function} type the type of mark to add; a constructor, such as
+ * <tt>pv.Bar</tt>.
+ * @returns {pv.Mark} the new mark.
+ * @see #extend
+ */
+pv.Mark.prototype.add = function(type) {
+  return this.parent.add(type).extend(this);
+};
+
+/**
+ * Defines a custom property on this mark. Custom properties are currently
+ * fixed, in that they are initialized once per mark set (i.e., per parent panel
+ * instance). Custom properties can be used to store local state for the mark,
+ * such as data needed by other properties (e.g., a custom scale) or interaction
+ * state.
+ *
+ * <p>WARNING We plan on changing this feature in a future release to define
+ * standard properties, as opposed to <i>fixed</i> properties that behave
+ * idiosyncratically within event handlers. Furthermore, we recommend storing
+ * state in an external data structure, rather than tying it to the
+ * visualization specification as with defs.
+ *
+ * @param {string} name the name of the local variable.
+ * @param {function} [v] an optional initializer; may be a constant or a
+ * function.
+ */
+pv.Mark.prototype.def = function(name, v) {
+  this.propertyMethod(name, true);
+  return this[name](arguments.length > 1 ? v : null);
+};
+
+/**
+ * Returns an anchor with the specified name. All marks support the five
+ * standard anchor names:<ul>
+ *
+ * <li>top
+ * <li>left
+ * <li>center
+ * <li>bottom
+ * <li>right
+ *
+ * </ul>In addition to positioning properties (left, right, top bottom), the
+ * anchors support text rendering properties (text-align, text-baseline). Text is
+ * rendered to appear inside the mark by default.
+ *
+ * <p>To facilitate stacking, anchors are defined in terms of their opposite
+ * edge. For example, the top anchor defines the bottom property, such that the
+ * mark extends upwards; the bottom anchor instead defines the top property,
+ * such that the mark extends downwards. See also {@link pv.Layout.Stack}.
+ *
+ * <p>While anchor names are typically constants, the anchor name is a true
+ * property, which means you can specify a function to compute the anchor name
+ * dynamically. See the {@link pv.Anchor#name} property for details.
+ *
+ * @param {string} name the anchor name; either a string or a property function.
+ * @returns {pv.Anchor} the new anchor.
+ */
+pv.Mark.prototype.anchor = function(name) {
+  if (!name) name = "center"; // default anchor name
+  return new pv.Anchor(this)
+    .name(name)
+    .data(function() {
+        return this.scene.target.map(function(s) { return s.data; });
+      })
+    .visible(function() {
+        return this.scene.target[this.index].visible;
+      })
+    .id(function() {
+        return this.scene.target[this.index].id;
+      })
+    .left(function() {
+        var s = this.scene.target[this.index], w = s.width || 0;
+        switch (this.name()) {
+          case "bottom":
+          case "top":
+          case "center": return s.left + w / 2;
+          case "left": return null;
+        }
+        return s.left + w;
+      })
+    .top(function() {
+        var s = this.scene.target[this.index], h = s.height || 0;
+        switch (this.name()) {
+          case "left":
+          case "right":
+          case "center": return s.top + h / 2;
+          case "top": return null;
+        }
+        return s.top + h;
+      })
+    .right(function() {
+        var s = this.scene.target[this.index];
+        return this.name() == "left" ? s.right + (s.width || 0) : null;
+      })
+    .bottom(function() {
+        var s = this.scene.target[this.index];
+        return this.name() == "top" ? s.bottom + (s.height || 0) : null;
+      })
+    .textAlign(function() {
+        switch (this.name()) {
+          case "bottom":
+          case "top":
+          case "center": return "center";
+          case "right": return "right";
+        }
+        return "left";
+      })
+    .textBaseline(function() {
+        switch (this.name()) {
+          case "right":
+          case "left":
+          case "center": return "middle";
+          case "top": return "top";
+        }
+        return "bottom";
+      });
+};
+
+/** @deprecated Replaced by {@link #target}. */
+pv.Mark.prototype.anchorTarget = function() {
+  return this.target;
+};
+
+/**
+ * Alias for setting the left, right, top and bottom properties simultaneously.
+ *
+ * @see #left
+ * @see #right
+ * @see #top
+ * @see #bottom
+ * @returns {pv.Mark} this.
+ */
+pv.Mark.prototype.margin = function(n) {
+  return this.left(n).right(n).top(n).bottom(n);
+};
+
+/**
+ * @private Returns the current instance of this mark in the scene graph. This
+ * is typically equivalent to <tt>this.scene[this.index]</tt>, however if the
+ * scene or index is unset, the default instance of the mark is returned. If no
+ * default is set, the default is the last instance. Similarly, if the scene or
+ * index of the parent panel is unset, the default instance of this mark in the
+ * last instance of the enclosing panel is returned, and so on.
+ *
+ * @returns a node in the scene graph.
+ */
+pv.Mark.prototype.instance = function(defaultIndex) {
+  var scene = this.scene || this.parent.instance(-1).children[this.childIndex],
+      index = !arguments.length || this.hasOwnProperty("index") ? this.index : defaultIndex;
+  return scene[index < 0 ? scene.length - 1 : index];
+};
+
+/**
+ * @private Find the instances of this mark that match source.
+ *
+ * @see pv.Anchor
+ */
+pv.Mark.prototype.instances = function(source) {
+  var mark = this, index = [], scene;
+
+  /* Mirrored descent. */
+  while (!(scene = mark.scene)) {
+    source = source.parent;
+    index.push({index: source.index, childIndex: mark.childIndex});
+    mark = mark.parent;
+  }
+  while (index.length) {
+    var i = index.pop();
+    scene = scene[i.index].children[i.childIndex];
+  }
+
+  /*
+   * When the anchor target is also an ancestor, as in the case of adding
+   * to a panel anchor, only generate one instance per panel. Also, set
+   * the margins to zero, since they are offset by the enclosing panel.
+   */
+  if (this.hasOwnProperty("index")) {
+    var s = pv.extend(scene[this.index]);
+    s.right = s.top = s.left = s.bottom = 0;
+    return [s];
+  }
+  return scene;
+};
+
+/**
+ * @private Returns the first instance of this mark in the scene graph. This
+ * method can only be called when the mark is bound to the scene graph (for
+ * example, from an event handler, or within a property function).
+ *
+ * @returns a node in the scene graph.
+ */
+pv.Mark.prototype.first = function() {
+  return this.scene[0];
+};
+
+/**
+ * @private Returns the last instance of this mark in the scene graph. This
+ * method can only be called when the mark is bound to the scene graph (for
+ * example, from an event handler, or within a property function). In addition,
+ * note that mark instances are built sequentially, so the last instance of this
+ * mark may not yet be constructed.
+ *
+ * @returns a node in the scene graph.
+ */
+pv.Mark.prototype.last = function() {
+  return this.scene[this.scene.length - 1];
+};
+
+/**
+ * @private Returns the previous instance of this mark in the scene graph, or
+ * null if this is the first instance.
+ *
+ * @returns a node in the scene graph, or null.
+ */
+pv.Mark.prototype.sibling = function() {
+  return (this.index == 0) ? null : this.scene[this.index - 1];
+};
+
+/**
+ * @private Returns the current instance in the scene graph of this mark, in the
+ * previous instance of the enclosing parent panel. May return null if this
+ * instance could not be found.
+ *
+ * @returns a node in the scene graph, or null.
+ */
+pv.Mark.prototype.cousin = function() {
+  var p = this.parent, s = p && p.sibling();
+  return (s && s.children) ? s.children[this.childIndex][this.index] : null;
+};
+
+/**
+ * Renders this mark, including recursively rendering all child marks if this is
+ * a panel. This method finds all instances of this mark and renders them. This
+ * method descends recursively to the level of the mark to be rendered, finding
+ * all visible instances of the mark. After the marks are rendered, the scene
+ * and index attributes are removed from the mark to restore them to a clean
+ * state.
+ *
+ * <p>If an enclosing panel has an index property set (as is the case inside in
+ * an event handler), then only instances of this mark inside the given instance
+ * of the panel will be rendered; otherwise, all visible instances of the mark
+ * will be rendered.
+ */
+pv.Mark.prototype.render = function() {
+  var parent = this.parent,
+      stack = pv.Mark.stack;
+
+  /* For the first render, take it from the top. */
+  if (parent && !this.root.scene) {
+    this.root.render();
+    return;
+  }
+
+  /* Record the path to this mark. */
+  var indexes = [];
+  for (var mark = this; mark.parent; mark = mark.parent) {
+    indexes.unshift(mark.childIndex);
+  }
+
+  /** @private */
+  function render(mark, depth, scale) {
+    mark.scale = scale;
+    if (depth < indexes.length) {
+      stack.unshift(null);
+      if (mark.hasOwnProperty("index")) {
+        renderInstance(mark, depth, scale);
+      } else {
+        for (var i = 0, n = mark.scene.length; i < n; i++) {
+          mark.index = i;
+          renderInstance(mark, depth, scale);
+        }
+        delete mark.index;
+      }
+      stack.shift();
+    } else {
+      mark.build();
+
+      /*
+       * In the update phase, the scene is rendered by creating and updating
+       * elements and attributes in the SVG image. No properties are evaluated
+       * during the update phase; instead the values computed previously in the
+       * build phase are simply translated into SVG. The update phase is
+       * decoupled (see pv.Scene) to allow different rendering engines.
+       */
+      pv.Scene.scale = scale;
+      pv.Scene.updateAll(mark.scene);
+    }
+    delete mark.scale;
+  }
+
+  /**
+   * @private Recursively renders the current instance of the specified mark.
+   * This is slightly tricky because `index` and `scene` properties may or may
+   * not already be set; if they are set, it means we are rendering only a
+   * specific instance; if they are unset, we are rendering all instances.
+   * Furthermore, we must preserve the original context of these properties when
+   * rendering completes.
+   *
+   * <p>Another tricky aspect is that the `scene` attribute should be set for
+   * any preceding children, so as to allow property chaining. This is
+   * consistent with first-pass rendering.
+   */
+  function renderInstance(mark, depth, scale) {
+    var s = mark.scene[mark.index], i;
+    if (s.visible) {
+      var childIndex = indexes[depth],
+          child = mark.children[childIndex];
+
+      /* Set preceding child scenes. */
+      for (i = 0; i < childIndex; i++) {
+        mark.children[i].scene = s.children[i];
+      }
+
+      /* Set current child scene, if necessary. */
+      stack[0] = s.data;
+      if (child.scene) {
+        render(child, depth + 1, scale * s.transform.k);
+      } else {
+        child.scene = s.children[childIndex];
+        render(child, depth + 1, scale * s.transform.k);
+        delete child.scene;
+      }
+
+      /* Clear preceding child scenes. */
+      for (i = 0; i < childIndex; i++) {
+        delete mark.children[i].scene;
+      }
+    }
+  }
+
+  /* Bind this mark's property definitions. */
+  this.bind();
+
+  /* The render context is the first ancestor with an explicit index. */
+  while (parent && !parent.hasOwnProperty("index")) parent = parent.parent;
+
+  /* Recursively render all instances of this mark. */
+  this.context(
+      parent ? parent.scene : undefined,
+      parent ? parent.index : -1,
+      function() { render(this.root, 0, 1); });
+};
+
+/** @private Stores the current data stack. */
+pv.Mark.stack = [];
+
+/**
+ * @private In the bind phase, inherited property definitions are cached so they
+ * do not need to be queried during build.
+ */
+pv.Mark.prototype.bind = function() {
+  var seen = {}, types = [[], [], [], []], data, required = [];
+
+  /** Scans the proto chain for the specified mark. */
+  function bind(mark) {
+    do {
+      var properties = mark.$properties;
+      for (var i = properties.length - 1; i >= 0 ; i--) {
+        var p = properties[i];
+        if (!(p.name in seen)) {
+          seen[p.name] = p;
+          switch (p.name) {
+            case "data": data = p; break;
+            case "visible": case "id": required.push(p); break;
+            default: types[p.type].push(p); break;
+          }
+        }
+      }
+    } while (mark = mark.proto);
+  }
+
+  /* Scan the proto chain for all defined properties. */
+  bind(this);
+  bind(this.defaults);
+  types[1].reverse();
+  types[3].reverse();
+
+  /* Any undefined properties are null. */
+  var mark = this;
+  do for (var name in mark.properties) {
+    if (!(name in seen)) {
+      types[2].push(seen[name] = {name: name, type: 2, value: null});
+    }
+  } while (mark = mark.proto);
+
+  /* Define setter-getter for inherited defs. */
+  var defs = types[0].concat(types[1]);
+  for (var i = 0; i < defs.length; i++) {
+    this.propertyMethod(defs[i].name, true);
+  }
+
+  /* Setup binds to evaluate constants before functions. */
+  this.binds = {
+    properties: seen,
+    data: data,
+    defs: defs,
+    required: required,
+    optional: pv.blend(types)
+  };
+};
+
+/**
+ * @private Evaluates properties and computes implied properties. Properties are
+ * stored in the {@link #scene} array for each instance of this mark.
+ *
+ * <p>As marks are built recursively, the {@link #index} property is updated to
+ * match the current index into the data array for each mark. Note that the
+ * index property is only set for the mark currently being built and its
+ * enclosing parent panels. The index property for other marks is unset, but is
+ * inherited from the global <tt>Mark</tt> class prototype. This allows mark
+ * properties to refer to properties on other marks <i>in the same panel</i>
+ * conveniently; however, in general it is better to reference mark instances
+ * specifically through the scene graph rather than depending on the magical
+ * behavior of {@link #index}.
+ *
+ * <p>The root scene array has a special property, <tt>data</tt>, which stores
+ * the current data stack. The first element in this stack is the current datum,
+ * followed by the datum of the enclosing parent panel, and so on. The data
+ * stack should not be accessed directly; instead, property functions are passed
+ * the current data stack as arguments.
+ *
+ * <p>The evaluation of the <tt>data</tt> and <tt>visible</tt> properties is
+ * special. The <tt>data</tt> property is evaluated first; unlike the other
+ * properties, the data stack is from the parent panel, rather than the current
+ * mark, since the data is not defined until the data property is evaluated.
+ * The <tt>visible</tt> property is subsequently evaluated for each instance;
+ * only if true will the {@link #buildInstance} method be called, evaluating
+ * other properties and recursively building the scene graph.
+ *
+ * <p>If this mark is being re-built, any old instances of this mark that no
+ * longer exist (because the new data array contains fewer elements) will be
+ * cleared using {@link #clearInstance}.
+ *
+ * @param parent the instance of the parent panel from the scene graph.
+ */
+pv.Mark.prototype.build = function() {
+  var scene = this.scene, stack = pv.Mark.stack;
+  if (!scene) {
+    scene = this.scene = [];
+    scene.mark = this;
+    scene.type = this.type;
+    scene.childIndex = this.childIndex;
+    if (this.parent) {
+      scene.parent = this.parent.scene;
+      scene.parentIndex = this.parent.index;
+    }
+  }
+
+  /* Resolve anchor target. */
+  if (this.target) scene.target = this.target.instances(scene);
+
+  /* Evaluate defs. */
+  if (this.binds.defs.length) {
+    var defs = scene.defs;
+    if (!defs) scene.defs = defs = {};
+    for (var i = 0; i < this.binds.defs.length; i++) {
+      var p = this.binds.defs[i], d = defs[p.name];
+      if (!d || (p.id > d.id)) {
+        defs[p.name] = {
+          id: 0, // this def will be re-evaluated on next build
+          value: (p.type & 1) ? p.value.apply(this, stack) : p.value
+        };
+      }
+    }
+  }
+
+  /* Evaluate special data property. */
+  var data = this.binds.data;
+  data = data.type & 1 ? data.value.apply(this, stack) : data.value;
+
+  /* Create, update and delete scene nodes. */
+  stack.unshift(null);
+  scene.length = data.length;
+  for (var i = 0; i < data.length; i++) {
+    pv.Mark.prototype.index = this.index = i;
+    var s = scene[i];
+    if (!s) scene[i] = s = {};
+    s.data = stack[0] = data[i];
+    this.buildInstance(s);
+  }
+  pv.Mark.prototype.index = -1;
+  delete this.index;
+  stack.shift();
+
+  return this;
+};
+
+/**
+ * @private Evaluates the specified array of properties for the specified
+ * instance <tt>s</tt> in the scene graph.
+ *
+ * @param s a node in the scene graph; the instance of the mark to build.
+ * @param properties an array of properties.
+ */
+pv.Mark.prototype.buildProperties = function(s, properties) {
+  for (var i = 0, n = properties.length; i < n; i++) {
+    var p = properties[i], v = p.value; // assume case 2 (constant)
+    switch (p.type) {
+      case 0:
+      case 1: v = this.scene.defs[p.name].value; break;
+      case 3: v = v.apply(this, pv.Mark.stack); break;
+    }
+    s[p.name] = v;
+  }
+};
+
+/**
+ * @private Evaluates all of the properties for this mark for the specified
+ * instance <tt>s</tt> in the scene graph. The set of properties to evaluate is
+ * retrieved from the {@link #properties} array for this mark type (see {@link
+ * #type}).  After these properties are evaluated, any <b>implied</b> properties
+ * may be computed by the mark and set on the scene graph; see
+ * {@link #buildImplied}.
+ *
+ * <p>For panels, this method recursively builds the scene graph for all child
+ * marks as well. In general, this method should not need to be overridden by
+ * concrete mark types.
+ *
+ * @param s a node in the scene graph; the instance of the mark to build.
+ */
+pv.Mark.prototype.buildInstance = function(s) {
+  this.buildProperties(s, this.binds.required);
+  if (s.visible) {
+    this.buildProperties(s, this.binds.optional);
+    this.buildImplied(s);
+  }
+};
+
+/**
+ * @private Computes the implied properties for this mark for the specified
+ * instance <tt>s</tt> in the scene graph. Implied properties are those with
+ * dependencies on multiple other properties; for example, the width property
+ * may be implied if the left and right properties are set. This method can be
+ * overridden by concrete mark types to define new implied properties, if
+ * necessary.
+ *
+ * @param s a node in the scene graph; the instance of the mark to build.
+ */
+pv.Mark.prototype.buildImplied = function(s) {
+  var l = s.left;
+  var r = s.right;
+  var t = s.top;
+  var b = s.bottom;
+
+  /* Assume width and height are zero if not supported by this mark type. */
+  var p = this.properties;
+  var w = p.width ? s.width : 0;
+  var h = p.height ? s.height : 0;
+
+  /* Compute implied width, right and left. */
+  var width = this.parent ? this.parent.width() : (w + l + r);
+  if (w == null) {
+    w = width - (r = r || 0) - (l = l || 0);
+  } else if (r == null) {
+    if (l == null) {
+      l = r = (width - w) / 2;
+    } else {
+      r = width - w - l;
+    }
+  } else if (l == null) {
+    l = width - w - r;
+  }
+
+  /* Compute implied height, bottom and top. */
+  var height = this.parent ? this.parent.height() : (h + t + b);
+  if (h == null) {
+    h = height - (t = t || 0) - (b = b || 0);
+  } else if (b == null) {
+    if (t == null) {
+      b = t = (height - h) / 2;
+    } else {
+      b = height - h - t;
+    }
+  } else if (t == null) {
+    t = height - h - b;
+  }
+
+  s.left = l;
+  s.right = r;
+  s.top = t;
+  s.bottom = b;
+
+  /* Only set width and height if they are supported by this mark type. */
+  if (p.width) s.width = w;
+  if (p.height) s.height = h;
+
+  /* Set any null colors to pv.Color.transparent. */
+  if (p.textStyle && !s.textStyle) s.textStyle = pv.Color.transparent;
+  if (p.fillStyle && !s.fillStyle) s.fillStyle = pv.Color.transparent;
+  if (p.strokeStyle && !s.strokeStyle) s.strokeStyle = pv.Color.transparent;
+};
+
+/**
+ * Returns the current location of the mouse (cursor) relative to this mark's
+ * parent. The <i>x</i> coordinate corresponds to the left margin, while the
+ * <i>y</i> coordinate corresponds to the top margin.
+ *
+ * @returns {pv.Vector} the mouse location.
+ */
+pv.Mark.prototype.mouse = function() {
+
+  /* Compute xy-coordinates relative to the panel. */
+  var x = pv.event.pageX || 0,
+      y = pv.event.pageY || 0,
+      n = this.root.canvas();
+  do {
+    x -= n.offsetLeft;
+    y -= n.offsetTop;
+  } while (n = n.offsetParent);
+
+  /* Compute the inverse transform of all enclosing panels. */
+  var t = pv.Transform.identity,
+      p = this.properties.transform ? this : this.parent,
+      pz = [];
+  do { pz.push(p); } while (p = p.parent);
+  while (p = pz.pop()) t = t.translate(p.left(), p.top()).times(p.transform());
+  t = t.invert();
+
+  return pv.vector(x * t.k + t.x, y * t.k + t.y);
+};
+
+/**
+ * Registers an event handler for the specified event type with this mark. When
+ * an event of the specified type is triggered, the specified handler will be
+ * invoked. The handler is invoked in a similar method to property functions:
+ * the context is <tt>this</tt> mark instance, and the arguments are the full
+ * data stack. Event handlers can use property methods to manipulate the display
+ * properties of the mark:
+ *
+ * <pre>m.event("click", function() this.fillStyle("red"));</pre>
+ *
+ * Alternatively, the external data can be manipulated and the visualization
+ * redrawn:
+ *
+ * <pre>m.event("click", function(d) {
+ *     data = all.filter(function(k) k.name == d);
+ *     vis.render();
+ *   });</pre>
+ *
+ * The return value of the event handler determines which mark gets re-rendered.
+ * Use defs ({@link #def}) to set temporary state from event handlers.
+ *
+ * <p>The complete set of event types is defined by SVG; see the reference
+ * below. The set of supported event types is:<ul>
+ *
+ * <li>click
+ * <li>mousedown
+ * <li>mouseup
+ * <li>mouseover
+ * <li>mousemove
+ * <li>mouseout
+ *
+ * </ul>Since Protovis does not specify any concept of focus, it does not
+ * support key events; these should be handled outside the visualization using
+ * standard JavaScript. In the future, support for interaction may be extended
+ * to support additional event types, particularly those most relevant to
+ * interactive visualization, such as selection.
+ *
+ * <p>TODO In the current implementation, event handlers are not inherited from
+ * prototype marks. They must be defined explicitly on each interactive mark. In
+ * addition, only one event handler for a given event type can be defined; when
+ * specifying multiple event handlers for the same type, only the last one will
+ * be used.
+ *
+ * @see <a href="http://www.w3.org/TR/SVGTiny12/interact.html#SVGEvents">SVG events</a>
+ * @param {string} type the event type.
+ * @param {function} handler the event handler.
+ * @returns {pv.Mark} this.
+ */
+pv.Mark.prototype.event = function(type, handler) {
+  this.$handlers[type] = pv.functor(handler);
+  return this;
+};
+
+/** @private Evaluates the function <i>f</i> with the specified context. */
+pv.Mark.prototype.context = function(scene, index, f) {
+  var proto = pv.Mark.prototype,
+      stack = pv.Mark.stack,
+      oscene = pv.Mark.scene,
+      oindex = proto.index;
+
+  /** @private Sets the context. */
+  function apply(scene, index) {
+    pv.Mark.scene = scene;
+    proto.index = index;
+    if (!scene) return;
+
+    var that = scene.mark,
+        mark = that,
+        ancestors = [];
+
+    /* Set ancestors' scene and index; populate data stack. */
+    do {
+      ancestors.push(mark);
+      stack.push(scene[index].data);
+      mark.index = index;
+      mark.scene = scene;
+      index = scene.parentIndex;
+      scene = scene.parent;
+    } while (mark = mark.parent);
+
+    /* Set ancestors' scale; requires top-down. */
+    for (var i = ancestors.length - 1, k = 1; i > 0; i--) {
+      mark = ancestors[i];
+      mark.scale = k;
+      k *= mark.scene[mark.index].transform.k;
+    }
+
+    /* Set children's scene and scale. */
+    if (that.children) for (var i = 0, n = that.children.length; i < n; i++) {
+      mark = that.children[i];
+      mark.scene = that.scene[that.index].children[i];
+      mark.scale = k;
+    }
+  }
+
+  /** @private Clears the context. */
+  function clear(scene, index) {
+    if (!scene) return;
+    var that = scene.mark,
+        mark;
+
+    /* Reset children. */
+    if (that.children) for (var i = 0, n = that.children.length; i < n; i++) {
+      mark = that.children[i];
+      delete mark.scene;
+      delete mark.scale;
+    }
+
+    /* Reset ancestors. */
+    mark = that;
+    do {
+      stack.pop();
+      if (mark.parent) {
+        delete mark.scene;
+        delete mark.scale;
+      }
+      delete mark.index;
+    } while (mark = mark.parent);
+  }
+
+  /* Context switch, invoke the function, then switch back. */
+  clear(oscene, oindex);
+  apply(scene, index);
+  try {
+    f.apply(this, stack);
+  } finally {
+    clear(scene, index);
+    apply(oscene, oindex);
+  }
+};
+
+/** @private Execute the event listener, then re-render. */
+pv.Mark.dispatch = function(type, scene, index) {
+  var m = scene.mark, p = scene.parent, l = m.$handlers[type];
+  if (!l) return p && pv.Mark.dispatch(type, p, scene.parentIndex);
+  m.context(scene, index, function() {
+      m = l.apply(m, pv.Mark.stack);
+      if (m && m.render) m.render();
+    });
+  return true;
+};
+
+pv.Mark.prototype.transition = function() {
+  return new pv.Transition(this);
+};
+
+pv.Mark.prototype.on = function(state) {
+  return this["$" + state] = new pv.Transient(this);
+};
diff --git a/vendor/protovis/src/mark/Panel.js b/vendor/protovis/src/mark/Panel.js
new file mode 100644
index 0000000..d040883
--- /dev/null
+++ b/vendor/protovis/src/mark/Panel.js
@@ -0,0 +1,273 @@
+/**
+ * Constructs a new, empty panel with default properties. Panels, with the
+ * exception of the root panel, are not typically constructed directly; instead,
+ * they are added to an existing panel or mark via {@link pv.Mark#add}.
+ *
+ * @class Represents a container mark. Panels allow repeated or nested
+ * structures, commonly used in small multiple displays where a small
+ * visualization is tiled to facilitate comparison across one or more
+ * dimensions. Other types of visualizations may benefit from repeated and
+ * possibly overlapping structure as well, such as stacked area charts. Panels
+ * can also offset the position of marks to provide padding from surrounding
+ * content.
+ *
+ * <p>All Protovis displays have at least one panel; this is the root panel to
+ * which marks are rendered. The box model properties (four margins, width and
+ * height) are used to offset the positions of contained marks. The data
+ * property determines the panel count: a panel is generated once per associated
+ * datum. When nested panels are used, property functions can declare additional
+ * arguments to access the data associated with enclosing panels.
+ *
+ * <p>Panels can be rendered inline, facilitating the creation of sparklines.
+ * This allows designers to reuse browser layout features, such as text flow and
+ * tables; designers can also overlay HTML elements such as rich text and
+ * images.
+ *
+ * <p>All panels have a <tt>children</tt> array (possibly empty) containing the
+ * child marks in the order they were added. Panels also have a <tt>root</tt>
+ * field which points to the root (outermost) panel; the root panel's root field
+ * points to itself.
+ *
+ * <p>See also the <a href="../../api/">Protovis guide</a>.
+ *
+ * @extends pv.Bar
+ */
+pv.Panel = function() {
+  pv.Bar.call(this);
+
+  /**
+   * The child marks; zero or more {@link pv.Mark}s in the order they were
+   * added.
+   *
+   * @see #add
+   * @type pv.Mark[]
+   */
+  this.children = [];
+  this.root = this;
+
+  /**
+   * The internal $dom field is set by the Protovis loader; see lang/init.js. It
+   * refers to the script element that contains the Protovis specification, so
+   * that the panel knows where in the DOM to insert the generated SVG element.
+   *
+   * @private
+   */
+  this.$dom = pv.$ && pv.$.s;
+};
+
+pv.Panel.prototype = pv.extend(pv.Bar)
+    .property("transform")
+    .property("overflow", String)
+    .property("canvas", function(c) {
+        return (typeof c == "string")
+            ? document.getElementById(c)
+            : c; // assume that c is the passed-in element
+      });
+
+pv.Panel.prototype.type = "panel";
+
+/**
+ * The canvas element; either the string ID of the canvas element in the current
+ * document, or a reference to the canvas element itself. If null, a canvas
+ * element will be created and inserted into the document at the location of the
+ * script element containing the current Protovis specification. This property
+ * only applies to root panels and is ignored on nested panels.
+ *
+ * <p>Note: the "canvas" element here refers to a <tt>div</tt> (or other suitable
+ * HTML container element), <i>not</i> a <tt>canvas</tt> element. The name of
+ * this property is a historical anachronism from the first implementation that
+ * used HTML 5 canvas, rather than SVG.
+ *
+ * @type string
+ * @name pv.Panel.prototype.canvas
+ */
+
+/**
+ * Specifies whether child marks are clipped when they overflow this panel.
+ * This affects the clipping of all this panel's descendant marks.
+ *
+ * @type string
+ * @name pv.Panel.prototype.overflow
+ * @see <a href="http://www.w3.org/TR/CSS2/visufx.html#overflow">CSS2</a>
+ */
+
+/**
+ * The transform to be applied to child marks. The default transform is
+ * identity, which has no effect. Note that the panel's own fill and stroke are
+ * not affected by the transform, and panel's transform only affects the
+ * <tt>scale</tt> of child marks, not the panel itself.
+ *
+ * @type pv.Transform
+ * @name pv.Panel.prototype.transform
+ * @see pv.Mark#scale
+ */
+
+/**
+ * Default properties for panels. By default, the margins are zero, the fill
+ * style is transparent.
+ *
+ * @type pv.Panel
+ */
+pv.Panel.prototype.defaults = new pv.Panel()
+    .extend(pv.Bar.prototype.defaults)
+    .fillStyle(null) // override Bar default
+    .overflow("visible");
+
+/**
+ * Returns an anchor with the specified name. This method is overridden such
+ * that adding to a panel's anchor adds to the panel, rather than to the panel's
+ * parent.
+ *
+ * @param {string} name the anchor name; either a string or a property function.
+ * @returns {pv.Anchor} the new anchor.
+ */
+pv.Panel.prototype.anchor = function(name) {
+  var anchor = pv.Bar.prototype.anchor.call(this, name);
+  anchor.parent = this;
+  return anchor;
+};
+
+/**
+ * Adds a new mark of the specified type to this panel. Unlike the normal
+ * {@link Mark#add} behavior, adding a mark to a panel does not cause the mark
+ * to inherit from the panel. Since the contained marks are offset by the panel
+ * margins already, inheriting properties is generally undesirable; of course,
+ * it is always possible to change this behavior by calling {@link Mark#extend}
+ * explicitly.
+ *
+ * @param {function} type the type of the new mark to add.
+ * @returns {pv.Mark} the new mark.
+ */
+pv.Panel.prototype.add = function(type) {
+  var child = new type();
+  child.parent = this;
+  child.root = this.root;
+  child.childIndex = this.children.length;
+  this.children.push(child);
+  return child;
+};
+
+/** @private Bind this panel, then any child marks recursively. */
+pv.Panel.prototype.bind = function() {
+  pv.Mark.prototype.bind.call(this);
+  for (var i = 0; i < this.children.length; i++) {
+    this.children[i].bind();
+  }
+};
+
+/**
+ * @private Evaluates all of the properties for this panel for the specified
+ * instance <tt>s</tt> in the scene graph, including recursively building the
+ * scene graph for child marks.
+ *
+ * @param s a node in the scene graph; the instance of the panel to build.
+ * @see Mark#scene
+ */
+pv.Panel.prototype.buildInstance = function(s) {
+  pv.Bar.prototype.buildInstance.call(this, s);
+  if (!s.visible) return;
+  if (!s.children) s.children = [];
+
+  /*
+   * Multiply the current scale factor by this panel's transform. Also clear the
+   * default index as we recurse into child marks; it will be reset to the
+   * current index when the next panel instance is built.
+   */
+  var scale = this.scale * s.transform.k, child, n = this.children.length;
+  pv.Mark.prototype.index = -1;
+
+  /*
+   * Build each child, passing in the parent (this panel) scene graph node. The
+   * child mark's scene is initialized from the corresponding entry in the
+   * existing scene graph, such that properties from the previous build can be
+   * reused; this is largely to facilitate the recycling of SVG elements.
+   */
+  for (var i = 0; i < n; i++) {
+    child = this.children[i];
+    child.scene = s.children[i]; // possibly undefined
+    child.scale = scale;
+    child.build();
+  }
+
+  /*
+   * Once the child marks have been built, the new scene graph nodes are removed
+   * from the child marks and placed into the scene graph. The nodes cannot
+   * remain on the child nodes because this panel (or a parent panel) may be
+   * instantiated multiple times!
+   */
+  for (var i = 0; i < n; i++) {
+    child = this.children[i];
+    s.children[i] = child.scene;
+    delete child.scene;
+    delete child.scale;
+  }
+
+  /* Delete any expired child scenes. */
+  s.children.length = n;
+};
+
+/**
+ * @private Computes the implied properties for this panel for the specified
+ * instance <tt>s</tt> in the scene graph. Panels have two implied
+ * properties:<ul>
+ *
+ * <li>The <tt>canvas</tt> property references the DOM element, typically a DIV,
+ * that contains the SVG element that is used to display the visualization. This
+ * property may be specified as a string, referring to the unique ID of the
+ * element in the DOM. The string is converted to a reference to the DOM
+ * element. The width and height of the SVG element is inferred from this DOM
+ * element. If no canvas property is specified, a new SVG element is created and
+ * inserted into the document, using the panel dimensions; see
+ * {@link #createCanvas}.
+ *
+ * <li>The <tt>children</tt> array, while not a property per se, contains the
+ * scene graph for each child mark. This array is initialized to be empty, and
+ * is populated above in {@link #buildInstance}.
+ *
+ * </ul>The current implementation creates the SVG element, if necessary, during
+ * the build phase; in the future, it may be preferrable to move this to the
+ * update phase, although then the canvas property would be undefined. In
+ * addition, DOM inspection is necessary to define the implied width and height
+ * properties that may be inferred from the DOM.
+ *
+ * @param s a node in the scene graph; the instance of the panel to build.
+ */
+pv.Panel.prototype.buildImplied = function(s) {
+  if (!this.parent) {
+    var c = s.canvas;
+    if (c) {
+      /* Clear the container if it's not associated with this panel. */
+      if (c.$panel != this) {
+        c.$panel = this;
+        while (c.lastChild) c.removeChild(c.lastChild);
+      }
+
+      /* If width and height weren't specified, inspect the container. */
+      var w, h;
+      if (s.width == null) {
+        w = parseFloat(pv.css(c, "width"));
+        s.width = w - s.left - s.right;
+      }
+      if (s.height == null) {
+        h = parseFloat(pv.css(c, "height"));
+        s.height = h - s.top - s.bottom;
+      }
+    } else {
+      var cache = this.$canvas || (this.$canvas = []);
+      if (!(c = cache[this.index])) {
+        c = cache[this.index] = document.createElement("span");
+        if (this.$dom) { // script element for text/javascript+protovis
+          this.$dom.parentNode.insertBefore(c, this.$dom);
+        } else { // find the last element in the body
+          var n = document.body;
+          while (n.lastChild && n.lastChild.tagName) n = n.lastChild;
+          if (n != document.body) n = n.parentNode;
+          n.appendChild(c);
+        }
+      }
+    }
+    s.canvas = c;
+  }
+  if (!s.transform) s.transform = pv.Transform.identity;
+  pv.Mark.prototype.buildImplied.call(this, s);
+};
diff --git a/vendor/protovis/src/mark/Rule.js b/vendor/protovis/src/mark/Rule.js
new file mode 100644
index 0000000..b7c622f
--- /dev/null
+++ b/vendor/protovis/src/mark/Rule.js
@@ -0,0 +1,143 @@
+/**
+ * Constructs a new rule with default properties. Rules are not typically
+ * constructed directly, but by adding to a panel or an existing mark via
+ * {@link pv.Mark#add}.
+ *
+ * @class Represents a horizontal or vertical rule. Rules are frequently used
+ * for axes and grid lines. For example, specifying only the bottom property
+ * draws horizontal rules, while specifying only the left draws vertical
+ * rules. Rules can also be used as thin bars. The visual style is controlled in
+ * the same manner as lines.
+ *
+ * <p>Rules are positioned exclusively the standard box model properties. The
+ * following combinations of properties are supported:
+ *
+ * <table>
+ * <thead><th style="width:12em;">Properties</th><th>Orientation</th></thead>
+ * <tbody>
+ * <tr><td>left</td><td>vertical</td></tr>
+ * <tr><td>right</td><td>vertical</td></tr>
+ * <tr><td>left, bottom, top</td><td>vertical</td></tr>
+ * <tr><td>right, bottom, top</td><td>vertical</td></tr>
+ * <tr><td>top</td><td>horizontal</td></tr>
+ * <tr><td>bottom</td><td>horizontal</td></tr>
+ * <tr><td>top, left, right</td><td>horizontal</td></tr>
+ * <tr><td>bottom, left, right</td><td>horizontal</td></tr>
+ * <tr><td>left, top, height</td><td>vertical</td></tr>
+ * <tr><td>left, bottom, height</td><td>vertical</td></tr>
+ * <tr><td>right, top, height</td><td>vertical</td></tr>
+ * <tr><td>right, bottom, height</td><td>vertical</td></tr>
+ * <tr><td>left, top, width</td><td>horizontal</td></tr>
+ * <tr><td>left, bottom, width</td><td>horizontal</td></tr>
+ * <tr><td>right, top, width</td><td>horizontal</td></tr>
+ * <tr><td>right, bottom, width</td><td>horizontal</td></tr>
+ * </tbody>
+ * </table>
+ *
+ * <p>Small rules can be used as tick marks; alternatively, a {@link Dot} with
+ * the "tick" shape can be used.
+ *
+ * <p>See also the <a href="../../api/Rule.html">Rule guide</a>.
+ *
+ * @see pv.Line
+ * @extends pv.Mark
+ */
+pv.Rule = function() {
+  pv.Mark.call(this);
+};
+
+pv.Rule.prototype = pv.extend(pv.Mark)
+    .property("width", Number)
+    .property("height", Number)
+    .property("lineWidth", Number)
+    .property("strokeStyle", pv.color);
+
+pv.Rule.prototype.type = "rule";
+
+/**
+ * The width of the rule, in pixels. If the left position is specified, the rule
+ * extends rightward from the left edge; if the right position is specified, the
+ * rule extends leftward from the right edge.
+ *
+ * @type number
+ * @name pv.Rule.prototype.width
+ */
+
+/**
+ * The height of the rule, in pixels. If the bottom position is specified, the
+ * rule extends upward from the bottom edge; if the top position is specified,
+ * the rule extends downward from the top edge.
+ *
+ * @type number
+ * @name pv.Rule.prototype.height
+ */
+
+/**
+ * The width of stroked lines, in pixels; used in conjunction with
+ * <tt>strokeStyle</tt> to stroke the rule. The default value is 1 pixel.
+ *
+ * @type number
+ * @name pv.Rule.prototype.lineWidth
+ */
+
+/**
+ * The style of stroked lines; used in conjunction with <tt>lineWidth</tt> to
+ * stroke the rule. The default value of this property is black.
+ *
+ * @type string
+ * @name pv.Rule.prototype.strokeStyle
+ * @see pv.color
+ */
+
+/**
+ * Default properties for rules. By default, a single-pixel black line is
+ * stroked.
+ *
+ * @type pv.Rule
+ */
+pv.Rule.prototype.defaults = new pv.Rule()
+    .extend(pv.Mark.prototype.defaults)
+    .lineWidth(1)
+    .strokeStyle("black")
+    .antialias(false);
+
+/**
+ * Constructs a new rule anchor with default properties. Rules support five
+ * different anchors:<ul>
+ *
+ * <li>top
+ * <li>left
+ * <li>center
+ * <li>bottom
+ * <li>right
+ *
+ * </ul>In addition to positioning properties (left, right, top bottom), the
+ * anchors support text rendering properties (text-align, text-baseline). Text is
+ * rendered to appear outside the rule. Note that this behavior is different
+ * from other mark anchors, which default to rendering text <i>inside</i> the
+ * mark.
+ *
+ * <p>For consistency with the other mark types, the anchor positions are
+ * defined in terms of their opposite edge. For example, the top anchor defines
+ * the bottom property, such that a bar added to the top anchor grows upward.
+ *
+ * @param {string} name the anchor name; either a string or a property function.
+ * @returns {pv.Anchor}
+ */
+pv.Rule.prototype.anchor = pv.Line.prototype.anchor;
+
+/** @private Sets width or height based on orientation. */
+pv.Rule.prototype.buildImplied = function(s) {
+  var l = s.left, r = s.right, t = s.top, b = s.bottom;
+
+  /* Determine horizontal or vertical orientation. */
+  if ((s.width != null)
+      || ((l == null) && (r == null))
+      || ((r != null) && (l != null))) {
+    s.height = 0;
+  } else {
+    s.width = 0;
+  }
+
+  pv.Mark.prototype.buildImplied.call(this, s);
+};
diff --git a/vendor/protovis/src/mark/Transient.js b/vendor/protovis/src/mark/Transient.js
new file mode 100644
index 0000000..e83c8ff
--- /dev/null
+++ b/vendor/protovis/src/mark/Transient.js
@@ -0,0 +1,7 @@
+pv.Transient = function(mark) {
+  pv.Mark.call(this);
+  this.fillStyle(null).strokeStyle(null).textStyle(null);
+  this.on = function(state) { return mark.on(state); };
+};
+
+pv.Transient.prototype = pv.extend(pv.Mark);
diff --git a/vendor/protovis/src/mark/Transition.js b/vendor/protovis/src/mark/Transition.js
new file mode 100644
index 0000000..dbf8e34
--- /dev/null
+++ b/vendor/protovis/src/mark/Transition.js
@@ -0,0 +1,195 @@
+pv.Transition = function(mark) {
+  var that = this,
+      ease = pv.ease("cubic-in-out"),
+      duration = 250,
+      timer;
+
+  var interpolated = {
+    top: 1,
+    left: 1,
+    right: 1,
+    bottom: 1,
+    width: 1,
+    height: 1,
+    innerRadius: 1,
+    outerRadius: 1,
+    radius: 1,
+    startAngle: 1,
+    endAngle: 1,
+    angle: 1,
+    fillStyle: 1,
+    strokeStyle: 1,
+    lineWidth: 1,
+    eccentricity: 1,
+    tension: 1,
+    textAngle: 1,
+    textStyle: 1,
+    textMargin: 1
+  };
+
+  var defaults = new pv.Transient();
+
+  var none = pv.Color.transparent;
+
+  /** @private */
+  function ids(marks) {
+    var map = {};
+    for (var i = 0; i < marks.length; i++) {
+      var mark = marks[i];
+      if (mark.id) map[mark.id] = mark;
+    }
+    return map;
+  }
+
+  /** @private */
+  function interpolateProperty(list, name, before, after) {
+    if (name in interpolated) {
+      var i = pv.Scale.interpolator(before[name], after[name]);
+      var f = function(t) { before[name] = i(t); }
+    } else {
+      var f = function(t) { if (t > .5) before[name] = after[name]; }
+    }
+    f.next = list.head;
+    list.head = f;
+  }
+
+  /** @private */
+  function interpolateInstance(list, before, after) {
+    for (var name in before) {
+      if (name == "children") continue; // not a property
+      if (before[name] == after[name]) continue; // unchanged
+      interpolateProperty(list, name, before, after);
+    }
+    if (before.children) {
+      for (var j = 0; j < before.children.length; j++) {
+        interpolate(list, before.children[j], after.children[j]);
+      }
+    }
+  }
+
+  /** @private */
+  function interpolate(list, before, after) {
+    var mark = before.mark, bi = ids(before), ai = ids(after);
+    for (var i = 0; i < before.length; i++) {
+      var b = before[i], a = b.id ? ai[b.id] : after[i];
+      b.index = i;
+      if (!b.visible) continue;
+      if (!(a && a.visible)) {
+        var o = override(before, i, mark.$exit, after);
+
+        /*
+         * After the transition finishes, we need to do a little cleanup to
+         * insure that the final state of the scenegraph is consistent with the
+         * "after" render. For instances that were removed, we need to remove
+         * them from the scenegraph; for instances that became invisible, we
+         * need to mark them invisible. See the cleanup method for details.
+         */
+        b.transition = a ? 2 : (after.push(o), 1);
+        a = o;
+      }
+      interpolateInstance(list, b, a);
+    }
+    for (var i = 0; i < after.length; i++) {
+      var a = after[i], b = a.id ? bi[a.id] : before[i];
+      if (!(b && b.visible) && a.visible) {
+        var o = override(after, i, mark.$enter, before);
+        if (!b) before.push(o);
+        else before[b.index] = o;
+        interpolateInstance(list, o, a);
+      }
+    }
+  }
+
+  /** @private */
+  function override(scene, index, proto, other) {
+    var s = pv.extend(scene[index]),
+        m = scene.mark,
+        r = m.root.scene,
+        p = (proto || defaults).$properties,
+        t;
+
+    /* Correct the target reference, if this is an anchor. */
+    if (other.target && (t = other.target[other.length])) {
+      scene = pv.extend(scene);
+      scene.target = pv.extend(other.target);
+      scene.target[index] = t;
+    }
+
+    /* Determine the set of properties to evaluate. */
+    var seen = {};
+    for (var i = 0; i < p.length; i++) seen[p[i].name] = 1;
+    p = m.binds.optional
+        .filter(function(p) { return !(p.name in seen); })
+        .concat(p);
+
+    /* Evaluate the properties and update any implied ones. */
+    m.context(scene, index, function() {
+      this.buildProperties(s, p);
+      this.buildImplied(s);
+    });
+
+    /* Restore the root scene. This should probably be done by context(). */
+    m.root.scene = r;
+    return s;
+  }
+
+  /** @private */
+  function cleanup(scene) {
+    for (var i = 0, j = 0; i < scene.length; i++) {
+      var s = scene[i];
+      if (s.transition != 1) {
+        scene[j++] = s;
+        if (s.transition == 2) s.visible = false;
+        if (s.children) s.children.forEach(cleanup);
+      }
+    }
+    scene.length = j;
+  }
+
+  that.ease = function(x) {
+    return arguments.length
+        ? (ease = typeof x == "function" ? x : pv.ease(x), that)
+        : ease;
+  };
+
+  that.duration = function(x) {
+    return arguments.length
+        ? (duration = Number(x), that)
+        : duration;
+  };
+
+  that.start = function() {
+    // TODO allow partial rendering
+    if (mark.parent) fail();
+
+    // TODO allow parallel and sequenced transitions
+    if (mark.$transition) mark.$transition.stop();
+    mark.$transition = that;
+
+    // TODO clearing the scene like this forces total re-build
+    var i = pv.Mark.prototype.index, before = mark.scene, after;
+    mark.scene = null;
+    mark.bind();
+    mark.build();
+    after = mark.scene;
+    mark.scene = before;
+    pv.Mark.prototype.index = i;
+
+    var start = Date.now(), list = {};
+    interpolate(list, before, after);
+    timer = setInterval(function() {
+      var t = Math.max(0, Math.min(1, (Date.now() - start) / duration)),
+          e = ease(t);
+      for (var i = list.head; i; i = i.next) i(e);
+      if (t == 1) {
+        cleanup(mark.scene);
+        that.stop();
+      }
+      pv.Scene.updateAll(before);
+    }, 24);
+  };
+
+  that.stop = function() {
+    clearInterval(timer);
+  };
+};
diff --git a/vendor/protovis/src/mark/Wedge.js b/vendor/protovis/src/mark/Wedge.js
new file mode 100644
index 0000000..0908f46
--- /dev/null
+++ b/vendor/protovis/src/mark/Wedge.js
@@ -0,0 +1,244 @@
+/**
+ * Constructs a new wedge with default properties. Wedges are not typically
+ * constructed directly, but by adding to a panel or an existing mark via
+ * {@link pv.Mark#add}.
+ *
+ * @class Represents a wedge, or pie slice. Specified in terms of start and end
+ * angle, inner and outer radius, wedges can be used to construct donut charts
+ * and polar bar charts as well. If the {@link #angle} property is used, the end
+ * angle is implied by adding this value to start angle. By default, the start
+ * angle is the previously-generated wedge's end angle. This design allows
+ * explicit control over the wedge placement if desired, while offering
+ * convenient defaults for the construction of radial graphs.
+ *
+ * <p>The center point of the circle is positioned using the standard box model.
+ * The wedge can be stroked and filled, similar to {@link pv.Bar}.
+ *
+ * <p>See also the <a href="../../api/Wedge.html">Wedge guide</a>.
+ *
+ * @extends pv.Mark
+ */
+pv.Wedge = function() {
+  pv.Mark.call(this);
+};
+
+pv.Wedge.prototype = pv.extend(pv.Mark)
+    .property("startAngle", Number)
+    .property("endAngle", Number)
+    .property("angle", Number)
+    .property("innerRadius", Number)
+    .property("outerRadius", Number)
+    .property("lineWidth", Number)
+    .property("strokeStyle", pv.color)
+    .property("fillStyle", pv.color);
+
+pv.Wedge.prototype.type = "wedge";
+
+/**
+ * The start angle of the wedge, in radians. The start angle is measured
+ * clockwise from the 3 o'clock position. The default value of this property is
+ * the end angle of the previous instance (the {@link Mark#sibling}), or -PI / 2
+ * for the first wedge; for pie and donut charts, typically only the
+ * {@link #angle} property needs to be specified.
+ *
+ * @type number
+ * @name pv.Wedge.prototype.startAngle
+ */
+
+/**
+ * The end angle of the wedge, in radians. If not specified, the end angle is
+ * implied as the start angle plus the {@link #angle}.
+ *
+ * @type number
+ * @name pv.Wedge.prototype.endAngle
+ */
+
+/**
+ * The angular span of the wedge, in radians. This property is used if end angle
+ * is not specified.
+ *
+ * @type number
+ * @name pv.Wedge.prototype.angle
+ */
+
+/**
+ * The inner radius of the wedge, in pixels. The default value of this property
+ * is zero; a positive value will produce a donut slice rather than a pie slice.
+ * The inner radius can vary per-wedge.
+ *
+ * @type number
+ * @name pv.Wedge.prototype.innerRadius
+ */
+
+/**
+ * The outer radius of the wedge, in pixels. This property is required. For
+ * pies, only this radius is required; for donuts, the inner radius must be
+ * specified as well. The outer radius can vary per-wedge.
+ *
+ * @type number
+ * @name pv.Wedge.prototype.outerRadius
+ */
+
+/**
+ * The width of stroked lines, in pixels; used in conjunction with
+ * <tt>strokeStyle</tt> to stroke the wedge's border.
+ *
+ * @type number
+ * @name pv.Wedge.prototype.lineWidth
+ */
+
+/**
+ * The style of stroked lines; used in conjunction with <tt>lineWidth</tt> to
+ * stroke the wedge's border. The default value of this property is null,
+ * meaning wedges are not stroked by default.
+ *
+ * @type string
+ * @name pv.Wedge.prototype.strokeStyle
+ * @see pv.color
+ */
+
+/**
+ * The wedge fill style; if non-null, the interior of the wedge is filled with
+ * the specified color. The default value of this property is a categorical
+ * color.
+ *
+ * @type string
+ * @name pv.Wedge.prototype.fillStyle
+ * @see pv.color
+ */
+
+/**
+ * Default properties for wedges. By default, there is no stroke and the fill
+ * style is a categorical color.
+ *
+ * @type pv.Wedge
+ */
+pv.Wedge.prototype.defaults = new pv.Wedge()
+    .extend(pv.Mark.prototype.defaults)
+    .startAngle(function() {
+        var s = this.sibling();
+        return s ? s.endAngle : -Math.PI / 2;
+      })
+    .innerRadius(0)
+    .lineWidth(1.5)
+    .strokeStyle(null)
+    .fillStyle(pv.Colors.category20().by(pv.index));
+
+/**
+ * Returns the mid-radius of the wedge, which is defined as half-way between the
+ * inner and outer radii.
+ *
+ * @see #innerRadius
+ * @see #outerRadius
+ * @returns {number} the mid-radius, in pixels.
+ */
+pv.Wedge.prototype.midRadius = function() {
+  return (this.innerRadius() + this.outerRadius()) / 2;
+};
+
+/**
+ * Returns the mid-angle of the wedge, which is defined as half-way between the
+ * start and end angles.
+ *
+ * @see #startAngle
+ * @see #endAngle
+ * @returns {number} the mid-angle, in radians.
+ */
+pv.Wedge.prototype.midAngle = function() {
+  return (this.startAngle() + this.endAngle()) / 2;
+};
+
+/**
+ * Constructs a new wedge anchor with default properties. Wedges support five
+ * different anchors:<ul>
+ *
+ * <li>outer
+ * <li>inner
+ * <li>center
+ * <li>start
+ * <li>end
+ *
+ * </ul>In addition to positioning properties (left, right, top bottom), the
+ * anchors support text rendering properties (text-align, text-baseline,
+ * textAngle). Text is rendered to appear inside the wedge.
+ *
+ * @param {string} name the anchor name; either a string or a property function.
+ * @returns {pv.Anchor}
+ */
+pv.Wedge.prototype.anchor = function(name) {
+  function partial(s) { return s.innerRadius || s.angle < 2 * Math.PI; }
+  function midRadius(s) { return (s.innerRadius + s.outerRadius) / 2; }
+  function midAngle(s) { return (s.startAngle + s.endAngle) / 2; }
+  return pv.Mark.prototype.anchor.call(this, name)
+    .left(function() {
+        var s = this.scene.target[this.index];
+        if (partial(s)) switch (this.name()) {
+          case "outer": return s.left + s.outerRadius * Math.cos(midAngle(s));
+          case "inner": return s.left + s.innerRadius * Math.cos(midAngle(s));
+          case "start": return s.left + midRadius(s) * Math.cos(s.startAngle);
+          case "center": return s.left + midRadius(s) * Math.cos(midAngle(s));
+          case "end": return s.left + midRadius(s) * Math.cos(s.endAngle);
+        }
+        return s.left;
+      })
+    .top(function() {
+        var s = this.scene.target[this.index];
+        if (partial(s)) switch (this.name()) {
+          case "outer": return s.top + s.outerRadius * Math.sin(midAngle(s));
+          case "inner": return s.top + s.innerRadius * Math.sin(midAngle(s));
+          case "start": return s.top + midRadius(s) * Math.sin(s.startAngle);
+          case "center": return s.top + midRadius(s) * Math.sin(midAngle(s));
+          case "end": return s.top + midRadius(s) * Math.sin(s.endAngle);
+        }
+        return s.top;
+      })
+    .textAlign(function() {
+        var s = this.scene.target[this.index];
+        if (partial(s)) switch (this.name()) {
+          case "outer": return pv.Wedge.upright(midAngle(s)) ? "right" : "left";
+          case "inner": return pv.Wedge.upright(midAngle(s)) ? "left" : "right";
+        }
+        return "center";
+      })
+    .textBaseline(function() {
+        var s = this.scene.target[this.index];
+        if (partial(s)) switch (this.name()) {
+          case "start": return pv.Wedge.upright(s.startAngle) ? "top" : "bottom";
+          case "end": return pv.Wedge.upright(s.endAngle) ? "bottom" : "top";
+        }
+        return "middle";
+      })
+    .textAngle(function() {
+        var s = this.scene.target[this.index], a = 0;
+        if (partial(s)) switch (this.name()) {
+          case "center":
+          case "inner":
+          case "outer": a = midAngle(s); break;
+          case "start": a = s.startAngle; break;
+          case "end": a = s.endAngle; break;
+        }
+        return pv.Wedge.upright(a) ? a : (a + Math.PI);
+      });
+};
+
+/**
+ * Returns true if the specified angle is considered "upright", as in, text
+ * rendered at that angle would appear upright. If the angle is not upright,
+ * text is rotated 180 degrees to be upright, and the text alignment properties
+ * are correspondingly changed.
+ *
+ * @param {number} angle an angle, in radius.
+ * @returns {boolean} true if the specified angle is upright.
+ */
+pv.Wedge.upright = function(angle) {
+  angle = angle % (2 * Math.PI);
+  angle = (angle < 0) ? (2 * Math.PI + angle) : angle;
+  return (angle < Math.PI / 2) || (angle >= 3 * Math.PI / 2);
+};
+
+/** @private Sets angle based on endAngle or vice versa. */
+pv.Wedge.prototype.buildImplied = function(s) {
+  if (s.angle == null) s.angle = s.endAngle - s.startAngle;
+  else if (s.endAngle == null) s.endAngle = s.startAngle + s.angle;
+  pv.Mark.prototype.buildImplied.call(this, s);
+};
diff --git a/vendor/protovis/src/physics/BoundConstraint.js b/vendor/protovis/src/physics/BoundConstraint.js
new file mode 100644
index 0000000..2627cb9
--- /dev/null
+++ b/vendor/protovis/src/physics/BoundConstraint.js
@@ -0,0 +1,75 @@
+/**
+ * Constructs a new bound constraint. Before the constraint can be used, the
+ * {@link #x} and {@link #y} methods must be call to specify the bounds.
+ *
+ * @class Constrains particles to within fixed rectangular bounds. For example,
+ * this constraint can be used to constrain particles in a physics simulation
+ * within the bounds of an enclosing panel.
+ *
+ * <p>Note that the current implementation treats particles as points, with no
+ * area. If the particles are rendered as dots, be sure to include some
+ * additional padding to inset the bounds such that the edges of the dots do not
+ * get clipped by the panel bounds. If the particles have different radii, this
+ * constraint would need to be extended using a radius function, similar to
+ * {@link pv.Constraint.collision}.
+ *
+ * @see pv.Layout.Force
+ * @extends pv.Constraint
+ */
+pv.Constraint.bound = function() {
+  var constraint = {},
+      x,
+      y;
+
+  /**
+   * Sets or gets the bounds on the x-coordinate.
+   *
+   * @function
+   * @name pv.Constraint.bound.prototype.x
+   * @param {number} min the minimum allowed x-coordinate.
+   * @param {number} max the maximum allowed x-coordinate.
+   * @returns {pv.Constraint.bound} this.
+   */
+  constraint.x = function(min, max) {
+    if (arguments.length) {
+      x = {min: Math.min(min, max), max: Math.max(min, max)};
+      return this;
+    }
+    return x;
+  };
+
+  /**
+   * Sets or gets the bounds on the y-coordinate.
+   *
+   * @function
+   * @name pv.Constraint.bound.prototype.y
+   * @param {number} min the minimum allowed y-coordinate.
+   * @param {number} max the maximum allowed y-coordinate.
+   * @returns {pv.Constraint.bound} this.
+   */
+  constraint.y = function(min, max) {
+    if (arguments.length) {
+      y = {min: Math.min(min, max), max: Math.max(min, max)};
+      return this;
+    }
+    return y;
+  };
+
+  /**
+   * Applies this constraint to the specified particles.
+   *
+   * @function
+   * @name pv.Constraint.bound.prototype.apply
+   * @param {pv.Particle} particles particles to which to apply this constraint.
+   */
+  constraint.apply = function(particles) {
+    if (x) for (var p = particles; p; p = p.next) {
+      p.x = p.x < x.min ? x.min : (p.x > x.max ? x.max : p.x);
+    }
+    if (y) for (var p = particles; p; p = p.next) {
+      p.y = p.y < y.min ? y.min : (p.y > y.max ? y.max : p.y);
+    }
+  };
+
+  return constraint;
+};
diff --git a/vendor/protovis/src/physics/ChargeForce.js b/vendor/protovis/src/physics/ChargeForce.js
new file mode 100644
index 0000000..53a36fc
--- /dev/null
+++ b/vendor/protovis/src/physics/ChargeForce.js
@@ -0,0 +1,184 @@
+/**
+ * Constructs a new charge force, with an optional charge constant. The charge
+ * constant can be negative for repulsion (e.g., particles with electrical
+ * charge of equal sign), or positive for attraction (e.g., massive particles
+ * with mutual gravity). The default charge constant is -40.
+ *
+ * @class An n-body force, as defined by Coulomb's law or Newton's law of
+ * gravitation, inversely proportional to the square of the distance between
+ * particles. Note that the force is independent of the <i>mass</i> of the
+ * associated particles, and that the particles do not have charges of varying
+ * magnitude; instead, the attraction or repulsion of all particles is globally
+ * specified as the charge {@link #constant}.
+ *
+ * <p>This particular implementation uses the Barnes-Hut algorithm. For details,
+ * see <a
+ * href="http://www.nature.com/nature/journal/v324/n6096/abs/324446a0.html">"A
+ * hierarchical O(N log N) force-calculation algorithm"</a>, J. Barnes &
+ * P. Hut, <i>Nature</i> 1986.
+ *
+ * @name pv.Force.charge
+ * @param {number} [k] the charge constant.
+ */
+pv.Force.charge = function(k) {
+  var min = 2, // minimum distance at which to observe forces
+      min1 = 1 / min,
+      max = 500, // maximum distance at which to observe forces
+      max1 = 1 / max,
+      theta = .9, // Barnes-Hut theta approximation constant
+      force = {};
+
+  if (!arguments.length) k = -40; // default charge constant (repulsion)
+
+  /**
+   * Sets or gets the charge constant. If an argument is specified, it is the
+   * new charge constant. The charge constant can be negative for repulsion
+   * (e.g., particles with electrical charge of equal sign), or positive for
+   * attraction (e.g., massive particles with mutual gravity). The default
+   * charge constant is -40.
+   *
+   * @function
+   * @name pv.Force.charge.prototype.constant
+   * @param {number} x the charge constant.
+   * @returns {pv.Force.charge} this.
+   */
+  force.constant = function(x) {
+    if (arguments.length) {
+      k = Number(x);
+      return force;
+    }
+    return k;
+  };
+
+  /**
+   * Sets or gets the domain; specifies the minimum and maximum domain within
+   * which charge forces are applied. A minimum distance threshold avoids
+   * applying forces that are two strong (due to granularity of the simulation's
+   * numeric integration). A maximum distance threshold improves performance by
+   * skipping force calculations for particles that are far apart.
+   *
+   * <p>The default domain is [2, 500].
+   *
+   * @function
+   * @name pv.Force.charge.prototype.domain
+   * @param {number} a
+   * @param {number} b
+   * @returns {pv.Force.charge} this.
+   */
+  force.domain = function(a, b) {
+    if (arguments.length) {
+      min = Number(a);
+      min1 = 1 / min;
+      max = Number(b);
+      max1 = 1 / max;
+      return force;
+    }
+    return [min, max];
+  };
+
+  /**
+   * Sets or gets the Barnes-Hut approximation factor. The Barnes-Hut
+   * approximation criterion is the ratio of the size of the quadtree node to
+   * the distance from the point to the node's center of mass is beneath some
+   * threshold.
+   *
+   * @function
+   * @name pv.Force.charge.prototype.theta
+   * @param {number} x the new Barnes-Hut approximation factor.
+   * @returns {pv.Force.charge} this.
+   */
+  force.theta = function(x) {
+    if (arguments.length) {
+      theta = Number(x);
+      return force;
+    }
+    return theta;
+  };
+
+  /**
+   * @ignore Recursively computes the center of charge for each node in the
+   * quadtree. This is equivalent to the center of mass, assuming that all
+   * particles have unit weight.
+   */
+  function accumulate(n) {
+    var cx = 0, cy = 0;
+    n.cn = 0;
+    function accumulateChild(c) {
+      accumulate(c);
+      n.cn += c.cn;
+      cx += c.cn * c.cx;
+      cy += c.cn * c.cy;
+    }
+    if (!n.leaf) {
+      if (n.c1) accumulateChild(n.c1);
+      if (n.c2) accumulateChild(n.c2);
+      if (n.c3) accumulateChild(n.c3);
+      if (n.c4) accumulateChild(n.c4);
+    }
+    if (n.p) {
+      n.cn += k;
+      cx += k * n.p.x;
+      cy += k * n.p.y;
+    }
+    n.cx = cx / n.cn;
+    n.cy = cy / n.cn;
+  }
+
+  /**
+   * @ignore Recursively computes forces on the given particle using the given
+   * quadtree node. The Barnes-Hut approximation criterion is the ratio of the
+   * size of the quadtree node to the distance from the point to the node's
+   * center of mass is beneath some threshold.
+   */
+  function forces(n, p, x1, y1, x2, y2) {
+    var dx = n.cx - p.x,
+        dy = n.cy - p.y,
+        dn = 1 / Math.sqrt(dx * dx + dy * dy);
+
+    /* Barnes-Hut criterion. */
+    if ((n.leaf && (n.p != p)) || ((x2 - x1) * dn < theta)) {
+      if (dn < max1) return;
+      if (dn > min1) dn = min1;
+      var kc = n.cn * dn * dn * dn,
+          fx = dx * kc,
+          fy = dy * kc;
+      p.fx += fx;
+      p.fy += fy;
+    } else if (!n.leaf) {
+      var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5;
+      if (n.c1) forces(n.c1, p, x1, y1, sx, sy);
+      if (n.c2) forces(n.c2, p, sx, y1, x2, sy);
+      if (n.c3) forces(n.c3, p, x1, sy, sx, y2);
+      if (n.c4) forces(n.c4, p, sx, sy, x2, y2);
+      if (dn < max1) return;
+      if (dn > min1) dn = min1;
+      if (n.p && (n.p != p)) {
+        var kc = k * dn * dn * dn,
+            fx = dx * kc,
+            fy = dy * kc;
+        p.fx += fx;
+        p.fy += fy;
+      }
+    }
+  }
+
+  /**
+   * Applies this force to the specified particles. The force is applied between
+   * all pairs of particles within the domain, using the specified quadtree to
+   * accelerate n-body force calculation using the Barnes-Hut approximation
+   * criterion.
+   *
+   * @function
+   * @name pv.Force.charge.prototype.apply
+   * @param {pv.Particle} particles particles to which to apply this force.
+   * @param {pv.Quadtree} q a quadtree for spatial acceleration.
+   */
+  force.apply = function(particles, q) {
+    accumulate(q.root);
+    for (var p = particles; p; p = p.next) {
+      forces(q.root, p, q.xMin, q.yMin, q.xMax, q.yMax);
+    }
+  };
+
+  return force;
+};
diff --git a/vendor/protovis/src/physics/CollisionConstraint.js b/vendor/protovis/src/physics/CollisionConstraint.js
new file mode 100644
index 0000000..f08bc23
--- /dev/null
+++ b/vendor/protovis/src/physics/CollisionConstraint.js
@@ -0,0 +1,113 @@
+/**
+ * Constructs a new collision constraint. The default search radius is 10, and
+ * the default repeat count is 1. A radius function must be specified to compute
+ * the radius of particles.
+ *
+ * @class Constraints circles to avoid overlap. Each particle is treated as a
+ * circle, with the radius of the particle computed using a specified function.
+ * For example, if the particle has an <tt>r</tt> attribute storing the radius,
+ * the radius <tt>function(d) d.r</tt> specifies a collision constraint using
+ * this radius. The radius function is passed each {@link pv.Particle} as the
+ * first argument.
+ *
+ * <p>To accelerate collision detection, this implementation uses a quadtree and
+ * a search radius. The search radius is computed as the maximum radius of all
+ * particles in the simulation.
+ *
+ * @see pv.Constraint
+ * @param {function} radius the radius function.
+ */
+pv.Constraint.collision = function(radius) {
+  var n = 1, // number of times to repeat the constraint
+      r1,
+      px1,
+      py1,
+      px2,
+      py2,
+      constraint = {};
+
+  if (!arguments.length) r1 = 10; // default search radius
+
+  /**
+   * Sets or gets the repeat count. If the repeat count is greater than 1, the
+   * constraint will be applied repeatedly; this is a form of the Gauss-Seidel
+   * method for constraints relaxation. Repeating the collision constraint makes
+   * the constraint have more of an effect when there is a potential for many
+   * co-occurring collisions.
+   *
+   * @function
+   * @name pv.Constraint.collision.prototype.repeat
+   * @param {number} x the number of times to repeat this constraint.
+   * @returns {pv.Constraint.collision} this.
+   */
+  constraint.repeat = function(x) {
+    if (arguments.length) {
+      n = Number(x);
+      return constraint;
+    }
+    return n;
+  };
+
+  /** @private */
+  function constrain(n, p, x1, y1, x2, y2) {
+    if (!n.leaf) {
+      var sx = (x1 + x2) * .5,
+          sy = (y1 + y2) * .5,
+          top = sy > py1,
+          bottom = sy < py2,
+          left = sx > px1,
+          right = sx < px2;
+      if (top) {
+        if (n.c1 && left) constrain(n.c1, p, x1, y1, sx, sy);
+        if (n.c2 && right) constrain(n.c2, p, sx, y1, x2, sy);
+      }
+      if (bottom) {
+        if (n.c3 && left) constrain(n.c3, p, x1, sy, sx, y2);
+        if (n.c4 && right) constrain(n.c4, p, sx, sy, x2, y2);
+      }
+    }
+    if (n.p && (n.p != p)) {
+      var dx = p.x - n.p.x,
+          dy = p.y - n.p.y,
+          l = Math.sqrt(dx * dx + dy * dy),
+          d = r1 + radius(n.p);
+      if (l < d) {
+        var k = (l - d) / l * .5;
+        dx *= k;
+        dy *= k;
+        p.x -= dx;
+        p.y -= dy;
+        n.p.x += dx;
+        n.p.y += dy;
+      }
+    }
+  }
+
+  /**
+   * Applies this constraint to the specified particles.
+   *
+   * @function
+   * @name pv.Constraint.collision.prototype.apply
+   * @param {pv.Particle} particles particles to which to apply this constraint.
+   * @param {pv.Quadtree} q a quadtree for spatial acceleration.
+   */
+  constraint.apply = function(particles, q) {
+    var p, r, max = -Infinity;
+    for (p = particles; p; p = p.next) {
+      r = radius(p);
+      if (r > max) max = r;
+    }
+    for (var i = 0; i < n; i++) {
+      for (p = particles; p; p = p.next) {
+        r = (r1 = radius(p)) + max;
+        px1 = p.x - r;
+        px2 = p.x + r;
+        py1 = p.y - r;
+        py2 = p.y + r;
+        constrain(q.root, p, q.xMin, q.yMin, q.xMax, q.yMax);
+      }
+    }
+  };
+
+  return constraint;
+};
diff --git a/vendor/protovis/src/physics/Constraint.js b/vendor/protovis/src/physics/Constraint.js
new file mode 100644
index 0000000..94f1842
--- /dev/null
+++ b/vendor/protovis/src/physics/Constraint.js
@@ -0,0 +1,26 @@
+/**
+ * Abstract; see an implementing class.
+ *
+ * @class Represents a constraint that acts on particles. Note that this
+ * interface does not specify how to bind a constraint to specific particles; in
+ * general, constraints are applied globally to all particles. However, some
+ * constraints may be applied to specific particles or between particles, such
+ * as position constraints, through additional specialization.
+ *
+ * @see pv.Simulation
+ * @see pv.Particle
+ * @see pv.Constraint.bound
+ * @see pv.Constraint.collision
+ * @see pv.Constraint.position
+ */
+pv.Constraint = {};
+
+/**
+ * Applies this constraint to the specified particles.
+ *
+ * @function
+ * @name pv.Constraint.prototype.apply
+ * @param {pv.Particle} particles particles to which to apply this constraint.
+ * @param {pv.Quadtree} q a quadtree for spatial acceleration.
+ * @returns {pv.Constraint} this.
+ */
diff --git a/vendor/protovis/src/physics/DragForce.js b/vendor/protovis/src/physics/DragForce.js
new file mode 100644
index 0000000..0ad6231
--- /dev/null
+++ b/vendor/protovis/src/physics/DragForce.js
@@ -0,0 +1,49 @@
+/**
+ * Constructs a new drag force with the specified constant.
+ *
+ * @class Implements a drag force, simulating friction. The drag force is
+ * applied in the opposite direction of the particle's velocity. Since Position
+ * Verlet integration does not track velocities explicitly, the error term with
+ * this estimate of velocity is fairly high, so the drag force may be
+ * inaccurate.
+ *
+ * @extends pv.Force
+ * @param {number} k the drag constant.
+ * @see #constant
+ */
+pv.Force.drag = function(k) {
+  var force = {};
+
+  if (!arguments.length) k = .1; // default drag constant
+
+  /**
+   * Sets or gets the drag constant, in the range [0,1]. The default drag
+   * constant is 0.1. The drag forces scales linearly with the particle's
+   * velocity based on the given drag constant.
+   *
+   * @function
+   * @name pv.Force.drag.prototype.constant
+   * @param {number} x the new drag constant.
+   * @returns {pv.Force.drag} this, or the current drag constant.
+   */
+  force.constant = function(x) {
+    if (arguments.length) { k = x; return force; }
+    return k;
+  };
+
+  /**
+   * Applies this force to the specified particles.
+   *
+   * @function
+   * @name pv.Force.drag.prototype.apply
+   * @param {pv.Particle} particles particles to which to apply this force.
+   */
+  force.apply = function(particles) {
+    if (k) for (var p = particles; p; p = p.next) {
+      p.fx -= k * p.vx;
+      p.fy -= k * p.vy;
+    }
+  };
+
+  return force;
+};
diff --git a/vendor/protovis/src/physics/Force.js b/vendor/protovis/src/physics/Force.js
new file mode 100644
index 0000000..f67943b
--- /dev/null
+++ b/vendor/protovis/src/physics/Force.js
@@ -0,0 +1,25 @@
+/**
+ * Abstract; see an implementing class.
+ *
+ * @class Represents a force that acts on particles. Note that this interface
+ * does not specify how to bind a force to specific particles; in general,
+ * forces are applied globally to all particles. However, some forces may be
+ * applied to specific particles or between particles, such as spring forces,
+ * through additional specialization.
+ *
+ * @see pv.Simulation
+ * @see pv.Particle
+ * @see pv.Force.charge
+ * @see pv.Force.drag
+ * @see pv.Force.spring
+ */
+pv.Force = {};
+
+/**
+ * Applies this force to the specified particles.
+ *
+ * @function
+ * @name pv.Force.prototype.apply
+ * @param {pv.Particle} particles particles to which to apply this force.
+ * @param {pv.Quadtree} q a quadtree for spatial acceleration.
+ */
diff --git a/vendor/protovis/src/physics/Particle.js b/vendor/protovis/src/physics/Particle.js
new file mode 100644
index 0000000..e41c864
--- /dev/null
+++ b/vendor/protovis/src/physics/Particle.js
@@ -0,0 +1,81 @@
+/**
+ * Abstract; not implemented. There is no explicit constructor; this class
+ * merely serves to document the attributes that are used on particles in
+ * physics simulations.
+ *
+ * @class A weighted particle that can participate in a force simulation.
+ *
+ * @name pv.Particle
+ */
+
+/**
+ * The next particle in the simulation. Particles form a singly-linked list.
+ *
+ * @field
+ * @type pv.Particle
+ * @name pv.Particle.prototype.next
+ */
+
+/**
+ * The <i>x</i>-position of the particle.
+ *
+ * @field
+ * @type number
+ * @name pv.Particle.prototype.x
+ */
+
+/**
+ * The <i>y</i>-position of the particle.
+ *
+ * @field
+ * @type number
+ * @name pv.Particle.prototype.y
+ */
+
+/**
+ * The <i>x</i>-velocity of the particle.
+ *
+ * @field
+ * @type number
+ * @name pv.Particle.prototype.vx
+ */
+
+/**
+ * The <i>y</i>-velocity of the particle.
+ *
+ * @field
+ * @type number
+ * @name pv.Particle.prototype.vy
+ */
+
+/**
+ * The <i>x</i>-position of the particle at -dt.
+ *
+ * @field
+ * @type number
+ * @name pv.Particle.prototype.px
+ */
+
+/**
+ * The <i>y</i>-position of the particle at -dt.
+ *
+ * @field
+ * @type number
+ * @name pv.Particle.prototype.py
+ */
+
+/**
+ * The <i>x</i>-force on the particle.
+ *
+ * @field
+ * @type number
+ * @name pv.Particle.prototype.fx
+ */
+
+/**
+ * The <i>y</i>-force on the particle.
+ *
+ * @field
+ * @type number
+ * @name pv.Particle.prototype.fy
+ */
diff --git a/vendor/protovis/src/physics/PositionConstraint.js b/vendor/protovis/src/physics/PositionConstraint.js
new file mode 100644
index 0000000..f7fa8d7
--- /dev/null
+++ b/vendor/protovis/src/physics/PositionConstraint.js
@@ -0,0 +1,72 @@
+/**
+ * Constructs a default position constraint using the <tt>fix</tt> attribute.
+ * An optional position function can be specified to determine how the fixed
+ * position per-particle is determined.
+ *
+ * @class Constraints particles to a fixed position. The fixed position per
+ * particle is determined using a given position function, which defaults to
+ * <tt>function(d) d.fix</tt>.
+ *
+ * <p>If the position function returns null, then no position constraint is
+ * applied to the given particle. Otherwise, the particle's position is set to
+ * the returned position, as expressed by a {@link pv.Vector}. (Note: the
+ * position does not need to be an instance of <tt>pv.Vector</tt>, but simply an
+ * object with <tt>x</tt> and <tt>y</tt> attributes.)
+ *
+ * <p>This constraint also supports a configurable alpha parameter, which
+ * defaults to 1. If the alpha parameter is in the range [0,1], then rather than
+ * setting the particle's new position directly to the position returned by the
+ * supplied position function, the particle's position is interpolated towards
+ * the fixed position. This results is a smooth (exponential) drift towards the
+ * fixed position, which can increase the stability of the physics simulation.
+ * In addition, the alpha parameter can be decayed over time, relaxing the
+ * position constraint, which helps to stabilize on an optimal solution.
+ *
+ * @param {function} [f] the position function.
+ */
+pv.Constraint.position = function(f) {
+  var a = 1, // default alpha
+      constraint = {};
+
+  if (!arguments.length) /** @ignore */ f = function(p) { return p.fix; };
+
+  /**
+   * Sets or gets the alpha parameter for position interpolation. If the alpha
+   * parameter is in the range [0,1], then rather than setting the particle's
+   * new position directly to the position returned by the supplied position
+   * function, the particle's position is interpolated towards the fixed
+   * position.
+   *
+   * @function
+   * @name pv.Constraint.position.prototype.alpha
+   * @param {number} x the new alpha parameter, in the range [0,1].
+   * @returns {pv.Constraint.position} this.
+   */
+  constraint.alpha = function(x) {
+    if (arguments.length) {
+      a = Number(x);
+      return constraint;
+    }
+    return a;
+  };
+
+  /**
+   * Applies this constraint to the specified particles.
+   *
+   * @function
+   * @name pv.Constraint.position.prototype.apply
+   * @param {pv.Particle} particles particles to which to apply this constraint.
+   */
+  constraint.apply = function(particles) {
+    for (var p = particles; p; p = p.next) {
+      var v = f(p);
+      if (v) {
+        p.x += (v.x - p.x) * a;
+        p.y += (v.y - p.y) * a;
+        p.fx = p.fy = p.vx = p.vy = 0;
+      }
+    }
+  };
+
+  return constraint;
+};
diff --git a/vendor/protovis/src/physics/Quadtree.js b/vendor/protovis/src/physics/Quadtree.js
new file mode 100644
index 0000000..6464255
--- /dev/null
+++ b/vendor/protovis/src/physics/Quadtree.js
@@ -0,0 +1,195 @@
+/**
+ * Constructs a new quadtree for the specified array of particles.
+ *
+ * @class Represents a quadtree: a two-dimensional recursive spatial
+ * subdivision. This particular implementation uses square partitions, dividing
+ * each square into four equally-sized squares. Each particle exists in a unique
+ * node; if multiple particles are in the same position, some particles may be
+ * stored on internal nodes rather than leaf nodes.
+ *
+ * <p>This quadtree can be used to accelerate various spatial operations, such
+ * as the Barnes-Hut approximation for computing n-body forces, or collision
+ * detection.
+ *
+ * @see pv.Force.charge
+ * @see pv.Constraint.collision
+ * @param {pv.Particle} particles the linked list of particles.
+ */
+pv.Quadtree = function(particles) {
+  var p;
+
+  /* Compute bounds. */
+  var x1 = Number.POSITIVE_INFINITY, y1 = x1,
+      x2 = Number.NEGATIVE_INFINITY, y2 = x2;
+  for (p = particles; p; p = p.next) {
+    if (p.x < x1) x1 = p.x;
+    if (p.y < y1) y1 = p.y;
+    if (p.x > x2) x2 = p.x;
+    if (p.y > y2) y2 = p.y;
+  }
+
+  /* Squarify the bounds. */
+  var dx = x2 - x1, dy = y2 - y1;
+  if (dx > dy) y2 = y1 + dx;
+  else x2 = x1 + dy;
+  this.xMin = x1;
+  this.yMin = y1;
+  this.xMax = x2;
+  this.yMax = y2;
+
+  /**
+   * @ignore Recursively inserts the specified particle <i>p</i> at the node
+   * <i>n</i> or one of its descendants. The bounds are defined by [<i>x1</i>,
+   * <i>x2</i>] and [<i>y1</i>, <i>y2</i>].
+   */
+  function insert(n, p, x1, y1, x2, y2) {
+    if (isNaN(p.x) || isNaN(p.y)) return; // ignore invalid particles
+    if (n.leaf) {
+      if (n.p) {
+        /*
+         * If the particle at this leaf node is at the same position as the new
+         * particle we are adding, we leave the particle associated with the
+         * internal node while adding the new particle to a child node. This
+         * avoids infinite recursion.
+         */
+        if ((Math.abs(n.p.x - p.x) + Math.abs(n.p.y - p.y)) < .01) {
+          insertChild(n, p, x1, y1, x2, y2);
+        } else {
+          var v = n.p;
+          n.p = null;
+          insertChild(n, v, x1, y1, x2, y2);
+          insertChild(n, p, x1, y1, x2, y2);
+        }
+      } else {
+        n.p = p;
+      }
+    } else {
+      insertChild(n, p, x1, y1, x2, y2);
+    }
+  }
+
+  /**
+   * @ignore Recursively inserts the specified particle <i>p</i> into a
+   * descendant of node <i>n</i>. The bounds are defined by [<i>x1</i>,
+   * <i>x2</i>] and [<i>y1</i>, <i>y2</i>].
+   */
+  function insertChild(n, p, x1, y1, x2, y2) {
+    /* Compute the split point, and the quadrant in which to insert p. */
+    var sx = (x1 + x2) * .5,
+        sy = (y1 + y2) * .5,
+        right = p.x >= sx,
+        bottom = p.y >= sy;
+
+    /* Recursively insert into the child node. */
+    n.leaf = false;
+    switch ((bottom << 1) + right) {
+      case 0: n = n.c1 || (n.c1 = new pv.Quadtree.Node()); break;
+      case 1: n = n.c2 || (n.c2 = new pv.Quadtree.Node()); break;
+      case 2: n = n.c3 || (n.c3 = new pv.Quadtree.Node()); break;
+      case 3: n = n.c4 || (n.c4 = new pv.Quadtree.Node()); break;
+    }
+
+    /* Update the bounds as we recurse. */
+    if (right) x1 = sx; else x2 = sx;
+    if (bottom) y1 = sy; else y2 = sy;
+    insert(n, p, x1, y1, x2, y2);
+  }
+
+  /* Insert all particles. */
+  this.root = new pv.Quadtree.Node();
+  for (p = particles; p; p = p.next) insert(this.root, p, x1, y1, x2, y2);
+};
+
+/**
+ * The root node of the quadtree.
+ *
+ * @type pv.Quadtree.Node
+ * @name pv.Quadtree.prototype.root
+ */
+
+/**
+ * The minimum x-coordinate value of all contained particles.
+ *
+ * @type number
+ * @name pv.Quadtree.prototype.xMin
+ */
+
+/**
+ * The maximum x-coordinate value of all contained particles.
+ *
+ * @type number
+ * @name pv.Quadtree.prototype.xMax
+ */
+
+/**
+ * The minimum y-coordinate value of all contained particles.
+ *
+ * @type number
+ * @name pv.Quadtree.prototype.yMin
+ */
+
+/**
+ * The maximum y-coordinate value of all contained particles.
+ *
+ * @type number
+ * @name pv.Quadtree.prototype.yMax
+ */
+
+/**
+ * Constructs a new node.
+ *
+ * @class A node in a quadtree.
+ *
+ * @see pv.Quadtree
+ */
+pv.Quadtree.Node = function() {
+  /*
+   * Prepopulating all attributes significantly increases performance! Also,
+   * letting the language interpreter manage garbage collection was moderately
+   * faster than creating a cache pool.
+   */
+  this.leaf = true;
+  this.c1 = null;
+  this.c2 = null;
+  this.c3 = null;
+  this.c4 = null;
+  this.p = null;
+};
+
+/**
+ * True if this node is a leaf node; i.e., it has no children. Note that both
+ * leaf nodes and non-leaf (internal) nodes may have associated particles. If
+ * this is a non-leaf node, then at least one of {@link #c1}, {@link #c2},
+ * {@link #c3} or {@link #c4} is guaranteed to be non-null.
+ *
+ * @type boolean
+ * @name pv.Quadtree.Node.prototype.leaf
+ */
+
+/**
+ * The particle associated with this node, if any.
+ *
+ * @type pv.Particle
+ * @name pv.Quadtree.Node.prototype.p
+ */
+
+/**
+ * The child node for the second quadrant, if any.
+ *
+ * @type pv.Quadtree.Node
+ * @name pv.Quadtree.Node.prototype.c2
+ */
+
+/**
+ * The child node for the third quadrant, if any.
+ *
+ * @type pv.Quadtree.Node
+ * @name pv.Quadtree.Node.prototype.c3
+ */
+
+/**
+ * The child node for the fourth quadrant, if any.
+ *
+ * @type pv.Quadtree.Node
+ * @name pv.Quadtree.Node.prototype.c4
+ */
diff --git a/vendor/protovis/src/physics/Simulation.js b/vendor/protovis/src/physics/Simulation.js
new file mode 100644
index 0000000..994b5b8
--- /dev/null
+++ b/vendor/protovis/src/physics/Simulation.js
@@ -0,0 +1,159 @@
+/**
+ * Constructs a new empty simulation.
+ *
+ * @param {array} particles
+ * @returns {pv.Simulation} a new simulation for the specified particles.
+ * @see pv.Simulation
+ */
+pv.simulation = function(particles) {
+  return new pv.Simulation(particles);
+};
+
+/**
+ * Constructs a new simulation for the specified particles.
+ *
+ * @class Represents a particle simulation. Particles are massive points in
+ * two-dimensional space. Forces can be applied to these particles, causing them
+ * to move. Constraints can also be applied to restrict particle movement, for
+ * example, constraining particles to a fixed position, or simulating collision
+ * between circular particles with area.
+ *
+ * <p>The simulation uses <a
+ * href="http://en.wikipedia.org/wiki/Verlet_integration">Position Verlet</a>
+ * integration, due to the ease with which <a
+ * href="http://www.teknikus.dk/tj/gdc2001.htm">geometric constraints</a> can be
+ * implemented. For each time step, Verlet integration is performed, new forces
+ * are accumulated, and then constraints are applied.
+ *
+ * <p>The simulation makes two simplifying assumptions: all particles are
+ * equal-mass, and the time step of the simulation is fixed. It would be easy to
+ * incorporate variable-mass particles as a future enhancement. Variable time
+ * steps are also possible, but are likely to introduce instability in the
+ * simulation.
+ *
+ * <p>This class can be used directly to simulate particle interaction.
+ * Alternatively, for network diagrams, see {@link pv.Layout.Force}.
+ *
+ * @param {array} particles an array of {@link pv.Particle}s to simulate.
+ * @see pv.Layout.Force
+ * @see pv.Force
+ * @see pv.Constraint
+ */
+pv.Simulation = function(particles) {
+  for (var i = 0; i < particles.length; i++) this.particle(particles[i]);
+};
+
+/**
+ * The particles in the simulation. Particles are stored as a linked list; this
+ * field represents the first particle in the simulation.
+ *
+ * @field
+ * @type pv.Particle
+ * @name pv.Simulation.prototype.particles
+ */
+
+/**
+ * The forces in the simulation. Forces are stored as a linked list; this field
+ * represents the first force in the simulation.
+ *
+ * @field
+ * @type pv.Force
+ * @name pv.Simulation.prototype.forces
+ */
+
+/**
+ * The constraints in the simulation. Constraints are stored as a linked list;
+ * this field represents the first constraint in the simulation.
+ *
+ * @field
+ * @type pv.Constraint
+ * @name pv.Simulation.prototype.constraints
+ */
+
+/**
+ * Adds the specified particle to the simulation.
+ *
+ * @param {pv.Particle} p the new particle.
+ * @returns {pv.Simulation} this.
+ */
+pv.Simulation.prototype.particle = function(p) {
+  p.next = this.particles;
+  /* Default velocities and forces to zero if unset. */
+  if (isNaN(p.px)) p.px = p.x;
+  if (isNaN(p.py)) p.py = p.y;
+  if (isNaN(p.fx)) p.fx = 0;
+  if (isNaN(p.fy)) p.fy = 0;
+  this.particles = p;
+  return this;
+};
+
+/**
+ * Adds the specified force to the simulation.
+ *
+ * @param {pv.Force} f the new force.
+ * @returns {pv.Simulation} this.
+ */
+pv.Simulation.prototype.force = function(f) {
+  f.next = this.forces;
+  this.forces = f;
+  return this;
+};
+
+/**
+ * Adds the specified constraint to the simulation.
+ *
+ * @param {pv.Constraint} c the new constraint.
+ * @returns {pv.Simulation} this.
+ */
+pv.Simulation.prototype.constraint = function(c) {
+  c.next = this.constraints;
+  this.constraints = c;
+  return this;
+};
+
+/**
+ * Apply constraints, and then set the velocities to zero.
+ *
+ * @returns {pv.Simulation} this.
+ */
+pv.Simulation.prototype.stabilize = function(n) {
+  var c;
+  if (!arguments.length) n = 3; // TODO use cooling schedule
+  for (var i = 0; i < n; i++) {
+    var q = new pv.Quadtree(this.particles);
+    for (c = this.constraints; c; c = c.next) c.apply(this.particles, q);
+  }
+  for (var p = this.particles; p; p = p.next) {
+    p.px = p.x;
+    p.py = p.y;
+  }
+  return this;
+};
+
+/**
+ * Advances the simulation one time-step.
+ */
+pv.Simulation.prototype.step = function() {
+  var p, f, c;
+
+  /*
+   * Assumptions:
+   * - The mass (m) of every particles is 1.
+   * - The time step (dt) is 1.
+   */
+
+  /* Position Verlet integration. */
+  for (p = this.particles; p; p = p.next) {
+    var px = p.px, py = p.py;
+    p.px = p.x;
+    p.py = p.y;
+    p.x += p.vx = ((p.x - px) + p.fx);
+    p.y += p.vy = ((p.y - py) + p.fy);
+  }
+
+  /* Apply constraints, then accumulate new forces. */
+  var q = new pv.Quadtree(this.particles);
+  for (c = this.constraints; c; c = c.next) c.apply(this.particles, q);
+  for (p = this.particles; p; p = p.next) p.fx = p.fy = 0;
+  for (f = this.forces; f; f = f.next) f.apply(this.particles, q);
+};
diff --git a/vendor/protovis/src/physics/SpringForce.js b/vendor/protovis/src/physics/SpringForce.js
new file mode 100644
index 0000000..d28902c
--- /dev/null
+++ b/vendor/protovis/src/physics/SpringForce.js
@@ -0,0 +1,141 @@
+/**
+ * Constructs a new spring force with the specified constant. The links
+ * associated with this spring force must be specified before the spring force
+ * can be applied.
+ *
+ * @class Implements a spring force, per Hooke's law. The spring force can be
+ * configured with a tension constant, rest length, and damping factor. The
+ * tension and damping will automatically be normalized using the inverse square
+ * root of the maximum link degree of attached nodes; this makes springs weaker
+ * between nodes of high link degree.
+ *
+ * <p>Unlike other forces (such as charge and drag forces) which may be applied
+ * globally, spring forces are only applied between linked particles. Therefore,
+ * an array of links must be specified before this force can be applied; the
+ * links should be an array of {@link pv.Layout.Network.Link}s. See also
+ * {@link pv.Layout.Force} for an example of using spring and charge forces for
+ * network layout.
+ *
+ * @extends pv.Force
+ * @param {number} k the spring constant.
+ * @see #constant
+ * @see #links
+ */
+pv.Force.spring = function(k) {
+  var d = .1, // default damping factor
+      l = 20, // default rest length
+      links, // links on which to apply spring forces
+      kl, // per-spring normalization
+      force = {};
+
+  if (!arguments.length) k = .1; // default spring constant (tension)
+
+  /**
+   * Sets or gets the links associated with this spring force. Unlike other
+   * forces (such as charge and drag forces) which may be applied globally,
+   * spring forces are only applied between linked particles. Therefore, an
+   * array of links must be specified before this force can be applied; the
+   * links should be an array of {@link pv.Layout.Network.Link}s.
+   *
+   * @function
+   * @name pv.Force.spring.prototype.links
+   * @param {array} x the new array of links.
+   * @returns {pv.Force.spring} this, or the current array of links.
+   */
+  force.links = function(x) {
+    if (arguments.length) {
+      links = x;
+      kl = x.map(function(l) {
+          return 1 / Math.sqrt(Math.max(
+              l.sourceNode.linkDegree,
+              l.targetNode.linkDegree));
+        });
+      return force;
+    }
+    return links;
+  };
+
+  /**
+   * Sets or gets the spring constant. The default value is 0.1; greater values
+   * will result in stronger tension. The spring tension is automatically
+   * normalized using the inverse square root of the maximum link degree of
+   * attached nodes.
+   *
+   * @function
+   * @name pv.Force.spring.prototype.constant
+   * @param {number} x the new spring constant.
+   * @returns {pv.Force.spring} this, or the current spring constant.
+   */
+  force.constant = function(x) {
+    if (arguments.length) {
+      k = Number(x);
+      return force;
+    }
+    return k;
+  };
+
+  /**
+   * The spring damping factor, in the range [0,1]. Damping functions
+   * identically to drag forces, damping spring bounciness by applying a force
+   * in the opposite direction of attached nodes' velocities. The default value
+   * is 0.1. The spring damping is automatically normalized using the inverse
+   * square root of the maximum link degree of attached nodes.
+   *
+   * @function
+   * @name pv.Force.spring.prototype.damping
+   * @param {number} x the new spring damping factor.
+   * @returns {pv.Force.spring} this, or the current spring damping factor.
+   */
+  force.damping = function(x) {
+    if (arguments.length) {
+      d = Number(x);
+      return force;
+    }
+    return d;
+  };
+
+  /**
+   * The spring rest length. The default value is 20 pixels.
+   *
+   * @function
+   * @name pv.Force.spring.prototype.length
+   * @param {number} x the new spring rest length.
+   * @returns {pv.Force.spring} this, or the current spring rest length.
+   */
+  force.length = function(x) {
+    if (arguments.length) {
+      l = Number(x);
+      return force;
+    }
+    return l;
+  };
+
+  /**
+   * Applies this force to the specified particles.
+   *
+   * @function
+   * @name pv.Force.spring.prototype.apply
+   * @param {pv.Particle} particles particles to which to apply this force.
+   */
+  force.apply = function(particles) {
+    for (var i = 0; i < links.length; i++) {
+      var a = links[i].sourceNode,
+          b = links[i].targetNode,
+          dx = a.x - b.x,
+          dy = a.y - b.y,
+          dn = Math.sqrt(dx * dx + dy * dy),
+          dd = dn ? (1 / dn) : 1,
+          ks = k * kl[i], // normalized tension
+          kd = d * kl[i], // normalized damping
+          kk = (ks * (dn - l) + kd * (dx * (a.vx - b.vx) + dy * (a.vy - b.vy)) * dd) * dd,
+          fx = -kk * (dn ? dx : (.01 * (.5 - Math.random()))),
+          fy = -kk * (dn ? dy : (.01 * (.5 - Math.random())));
+      a.fx += fx;
+      a.fy += fy;
+      b.fx -= fx;
+      b.fy -= fy;
+    }
+  };
+
+  return force;
+};
diff --git a/vendor/protovis/src/pv-internals.js b/vendor/protovis/src/pv-internals.js
new file mode 100644
index 0000000..15d7aba
--- /dev/null
+++ b/vendor/protovis/src/pv-internals.js
@@ -0,0 +1,154 @@
+/**
+ * @private Returns a prototype object suitable for extending the given class
+ * <tt>f</tt>. Rather than constructing a new instance of <tt>f</tt> to serve as
+ * the prototype (which unnecessarily runs the constructor on the created
+ * prototype object, potentially polluting it), an anonymous function is
+ * generated internally that shares the same prototype:
+ *
+ * <pre>function g() {}
+ * g.prototype = f.prototype;
+ * return new g();</pre>
+ *
+ * For more details, see Douglas Crockford's essay on prototypal inheritance.
+ *
+ * @param {function} f a constructor.
+ * @returns a suitable prototype object.
+ * @see Douglas Crockford's essay on <a
+ * href="http://javascript.crockford.com/prototypal.html">prototypal
+ * inheritance</a>.
+ */
+pv.extend = function(f) {
+  function g() {}
+  g.prototype = f.prototype || f;
+  return new g();
+};
+
+try {
+  eval("pv.parse = function(x) x;"); // native support
+} catch (e) {
+
+/**
+ * @private Parses a Protovis specification, which may use JavaScript 1.8
+ * function expresses, replacing those function expressions with proper
+ * functions such that the code can be run by a JavaScript 1.6 interpreter. This
+ * hack only supports function expressions (using clumsy regular expressions, no
+ * less), and not other JavaScript 1.8 features such as let expressions.
+ *
+ * @param {string} s a Protovis specification (i.e., a string of JavaScript 1.8
+ * source code).
+ * @returns {string} a conformant JavaScript 1.6 source code.
+ */
+  pv.parse = function(js) { // hacky regex support
+    var re = new RegExp("function\\s*(\\b\\w+)?\\s*\\([^)]*\\)\\s*", "mg"), m, d, i = 0, s = "";
+    while (m = re.exec(js)) {
+      var j = m.index + m[0].length;
+      if (js.charAt(j) != '{') {
+        s += js.substring(i, j) + "{return ";
+        i = j;
+        for (var p = 0; p >= 0 && j < js.length; j++) {
+          var c = js.charAt(j);
+          switch (c) {
+            case '"': case '\'': {
+              while (++j < js.length && (d = js.charAt(j)) != c) {
+                if (d == '\\') j++;
+              }
+              break;
+            }
+            case '[': case '(': p++; break;
+            case ']': case ')': p--; break;
+            case ';':
+            case ',': if (p == 0) p--; break;
+          }
+        }
+        s += pv.parse(js.substring(i, --j)) + ";}";
+        i = j;
+      }
+      re.lastIndex = j;
+    }
+    s += js.substring(i);
+    return s;
+  };
+}
+
+/**
+ * @private Computes the value of the specified CSS property <tt>p</tt> on the
+ * specified element <tt>e</tt>.
+ *
+ * @param {string} p the name of the CSS property.
+ * @param e the element on which to compute the CSS property.
+ */
+pv.css = function(e, p) {
+  return window.getComputedStyle
+      ? window.getComputedStyle(e, null).getPropertyValue(p)
+      : e.currentStyle[p];
+};
+
+/**
+ * @private Reports the specified error to the JavaScript console. Mozilla only
+ * allows logging to the console for privileged code; if the console is
+ * unavailable, the alert dialog box is used instead.
+ *
+ * @param e the exception that triggered the error.
+ */
+pv.error = function(e) {
+  (typeof console == "undefined") ? alert(e) : console.error(e);
+};
+
+/**
+ * @private Registers the specified listener for events of the specified type on
+ * the specified target. For standards-compliant browsers, this method uses
+ * <tt>addEventListener</tt>; for Internet Explorer, <tt>attachEvent</tt>.
+ *
+ * @param target a DOM element.
+ * @param {string} type the type of event, such as "click".
+ * @param {function} the event handler callback.
+ */
+pv.listen = function(target, type, listener) {
+  listener = pv.listener(listener);
+  return target.addEventListener
+      ? target.addEventListener(type, listener, false)
+      : target.attachEvent("on" + type, listener);
+};
+
+/**
+ * @private Returns a wrapper for the specified listener function such that the
+ * {@link pv.event} is set for the duration of the listener's invocation. The
+ * wrapper is cached on the returned function, such that duplicate registrations
+ * of the wrapped event handler are ignored.
+ *
+ * @param {function} f an event handler.
+ * @returns {function} the wrapped event handler.
+ */
+pv.listener = function(f) {
+  return f.$listener || (f.$listener = function(e) {
+      try {
+        pv.event = e;
+        return f.call(this, e);
+      } finally {
+        delete pv.event;
+      }
+    });
+};
+
+/**
+ * @private Returns true iff <i>a</i> is an ancestor of <i>e</i>. This is useful
+ * for ignoring mouseout and mouseover events that are contained within the
+ * target element.
+ */
+pv.ancestor = function(a, e) {
+  while (e) {
+    if (e == a) return true;
+    e = e.parentNode;
+  }
+  return false;
+};
+
+/** @private Returns a locally-unique positive id. */
+pv.id = function() {
+  var id = 1; return function() { return id++; };
+}();
+
+/** @private Returns a function wrapping the specified constant. */
+pv.functor = function(v) {
+  return typeof v == "function" ? v : function() { return v; };
+};
diff --git a/vendor/protovis/src/pv.js b/vendor/protovis/src/pv.js
new file mode 100644
index 0000000..9ab8d88
--- /dev/null
+++ b/vendor/protovis/src/pv.js
@@ -0,0 +1,95 @@
+/**
+ * The top-level Protovis namespace. All public methods and fields should be
+ * registered on this object. Note that core Protovis source is surrounded by an
+ * anonymous function, so any other declared globals will not be visible outside
+ * of core methods. This also allows multiple versions of Protovis to coexist,
+ * since each version will see their own <tt>pv</tt> namespace.
+ *
+ * @namespace The top-level Protovis namespace, <tt>pv</tt>.
+ */
+var pv = {};
+
+/**
+ * Protovis major and minor version numbers.
+ *
+ * @namespace Protovis major and minor version numbers.
+ */
+pv.version = {
+  /**
+   * The major version number.
+   *
+   * @type number
+   * @constant
+   */
+  major: 3,
+
+  /**
+   * The minor version number.
+   *
+   * @type number
+   * @constant
+   */
+  minor: 3
+};
+
+/**
+ * Returns the passed-in argument, <tt>x</tt>; the identity function. This method
+ * is provided for convenience since it is used as the default behavior for a
+ * number of property functions.
+ *
+ * @param x a value.
+ * @returns the value <tt>x</tt>.
+ */
+pv.identity = function(x) { return x; };
+
+/**
+ * Returns <tt>this.index</tt>. This method is provided for convenience for use
+ * with scales. For example, to color bars by their index, say:
+ *
+ * <pre>.fillStyle(pv.Colors.category10().by(pv.index))</pre>
+ *
+ * This method is equivalent to <tt>function() this.index</tt>, but more
+ * succinct. Note that the <tt>index</tt> property is also supported for
+ * accessor functions with {@link pv.max}, {@link pv.min} and other array
+ * utility methods.
+ *
+ * @see pv.Scale
+ * @see pv.Mark#index
+ */
+pv.index = function() { return this.index; };
+
+/**
+ * Returns <tt>this.childIndex</tt>. This method is provided for convenience for
+ * use with scales. For example, to color bars by their child index, say:
+ *
+ * <pre>.fillStyle(pv.Colors.category10().by(pv.child))</pre>
+ *
+ * This method is equivalent to <tt>function() this.childIndex</tt>, but more
+ * succinct.
+ *
+ * @see pv.Scale
+ * @see pv.Mark#childIndex
+ */
+pv.child = function() { return this.childIndex; };
+
+/**
+ * Returns <tt>this.parent.index</tt>. This method is provided for convenience
+ * for use with scales. This method is provided for convenience for use with
+ * scales. For example, to color bars by their parent index, say:
+ *
+ * <pre>.fillStyle(pv.Colors.category10().by(pv.parent))</pre>
+ *
+ * Tthis method is equivalent to <tt>function() this.parent.index</tt>, but more
+ * succinct.
+ *
+ * @see pv.Scale
+ * @see pv.Mark#index
+ */
+pv.parent = function() { return this.parent.index; };
+
+/**
+ * Stores the current event. This field is only set within event handlers.
+ *
+ * @type Event
+ * @name pv.event
+ */
diff --git a/vendor/protovis/src/scene/SvgArea.js b/vendor/protovis/src/scene/SvgArea.js
new file mode 100644
index 0000000..5c7c563
--- /dev/null
+++ b/vendor/protovis/src/scene/SvgArea.js
@@ -0,0 +1,172 @@
+pv.SvgScene.area = function(scenes) {
+  var e = scenes.$g.firstChild;
+  if (!scenes.length) return e;
+  var s = scenes[0];
+
+  /* segmented */
+  if (s.segmented) return this.areaSegment(scenes);
+
+  /* visible */
+  if (!s.visible) return e;
+  var fill = s.fillStyle, stroke = s.strokeStyle;
+  if (!fill.opacity && !stroke.opacity) return e;
+
+  /** @private Computes the straight path for the range [i, j]. */
+  function path(i, j) {
+    var p1 = [], p2 = [];
+    for (var k = j; i <= k; i++, j--) {
+      var si = scenes[i],
+          sj = scenes[j],
+          pi = si.left + "," + si.top,
+          pj = (sj.left + sj.width) + "," + (sj.top + sj.height);
+
+      /* interpolate */
+      if (i < k) {
+        var sk = scenes[i + 1], sl = scenes[j - 1];
+        switch (s.interpolate) {
+          case "step-before": {
+            pi += "V" + sk.top;
+            pj += "H" + (sl.left + sl.width);
+            break;
+          }
+          case "step-after": {
+            pi += "H" + sk.left;
+            pj += "V" + (sl.top + sl.height);
+            break;
+          }
+        }
+      }
+
+      p1.push(pi);
+      p2.push(pj);
+    }
+    return p1.concat(p2).join("L");
+  }
+
+  /** @private Computes the curved path for the range [i, j]. */
+  function pathCurve(i, j) {
+    var pointsT = [], pointsB = [], pathT, pathB;
+
+    for (var k = j; i <= k; i++, j--) {
+      var sj = scenes[j];
+      pointsT.push(scenes[i]);
+      pointsB.push({left: sj.left + sj.width, top: sj.top + sj.height});
+    }
+
+    if (s.interpolate == "basis") {
+      pathT = pv.SvgScene.curveBasis(pointsT);
+      pathB = pv.SvgScene.curveBasis(pointsB);
+    } else if (s.interpolate == "cardinal") {
+      pathT = pv.SvgScene.curveCardinal(pointsT, s.tension);
+      pathB = pv.SvgScene.curveCardinal(pointsB, s.tension);
+    } else { // monotone
+      pathT = pv.SvgScene.curveMonotone(pointsT);
+      pathB = pv.SvgScene.curveMonotone(pointsB);
+    }
+
+    return pointsT[0].left + "," + pointsT[0].top + pathT
+         + "L" + pointsB[0].left + "," + pointsB[0].top + pathB;
+  }
+
+  /* points */
+  var d = [], si, sj;
+  for (var i = 0; i < scenes.length; i++) {
+    si = scenes[i]; if (!si.width && !si.height) continue;
+    for (var j = i + 1; j < scenes.length; j++) {
+      sj = scenes[j]; if (!sj.width && !sj.height) break;
+    }
+    if (i && (s.interpolate != "step-after")) i--;
+    if ((j < scenes.length) && (s.interpolate != "step-before")) j++;
+    d.push(((j - i > 2
+        && (s.interpolate == "basis"
+        || s.interpolate == "cardinal"
+        || s.interpolate == "monotone"))
+        ? pathCurve : path)(i, j - 1));
+    i = j - 1;
+  }
+  if (!d.length) return e;
+
+  e = this.expect(e, "path", {
+      "shape-rendering": s.antialias ? null : "crispEdges",
+      "pointer-events": s.events,
+      "cursor": s.cursor,
+      "d": "M" + d.join("ZM") + "Z",
+      "fill": fill.color,
+      "fill-opacity": fill.opacity || null,
+      "stroke": stroke.color,
+      "stroke-opacity": stroke.opacity || null,
+      "stroke-width": stroke.opacity ? s.lineWidth / this.scale : null
+    });
+  return this.append(e, scenes, 0);
+};
+
+pv.SvgScene.areaSegment = function(scenes) {
+  var e = scenes.$g.firstChild, s = scenes[0], pathsT, pathsB;
+  if (s.interpolate == "basis"
+      || s.interpolate == "cardinal"
+      || s.interpolate == "monotone") {
+    var pointsT = [], pointsB = [];
+
+    for (var i = 0, n = scenes.length; i < n; i++) {
+      var sj = scenes[n - i - 1];
+      pointsT.push(scenes[i]);
+      pointsB.push({left: sj.left + sj.width, top: sj.top + sj.height});
+    }
+
+    if (s.interpolate == "basis") {
+      pathsT = this.curveBasisSegments(pointsT);
+      pathsB = this.curveBasisSegments(pointsB);
+    } else if (s.interpolate == "cardinal") {
+      pathsT = this.curveCardinalSegments(pointsT, s.tension);
+      pathsB = this.curveCardinalSegments(pointsB, s.tension);
+    } else { // monotone
+      pathsT = this.curveMonotoneSegments(pointsT);
+      pathsB = this.curveMonotoneSegments(pointsB);
+    }
+  }
+
+  for (var i = 0, n = scenes.length - 1; i < n; i++) {
+    var s1 = scenes[i], s2 = scenes[i + 1];
+
+    /* visible */
+    if (!s1.visible || !s2.visible) continue;
+    var fill = s1.fillStyle, stroke = s1.strokeStyle;
+    if (!fill.opacity && !stroke.opacity) continue;
+
+    var d;
+    if (pathsT) {
+      var pathT = pathsT[i],
+          pathB = "L" + pathsB[n - i - 1].substr(1);
+
+      d = pathT + pathB + "Z";
+    } else {
+      /* interpolate */
+      var si = s1, sj = s2;
+      switch (s1.interpolate) {
+        case "step-before": si = s2; break;
+        case "step-after": sj = s1; break;
+      }
+
+      /* path */
+      d = "M" + s1.left + "," + si.top
+        + "L" + s2.left + "," + sj.top
+        + "L" + (s2.left + s2.width) + "," + (sj.top + sj.height)
+        + "L" + (s1.left + s1.width) + "," + (si.top + si.height)
+        + "Z";
+    }
+
+    e = this.expect(e, "path", {
+        "shape-rendering": s1.antialias ? null : "crispEdges",
+        "pointer-events": s1.events,
+        "cursor": s1.cursor,
+        "d": d,
+        "fill": fill.color,
+        "fill-opacity": fill.opacity || null,
+        "stroke": stroke.color,
+        "stroke-opacity": stroke.opacity || null,
+        "stroke-width": stroke.opacity ? s1.lineWidth / this.scale : null
+      });
+    e = this.append(e, scenes, i);
+  }
+  return e;
+};
diff --git a/vendor/protovis/src/scene/SvgBar.js b/vendor/protovis/src/scene/SvgBar.js
new file mode 100644
index 0000000..f60ae2d
--- /dev/null
+++ b/vendor/protovis/src/scene/SvgBar.js
@@ -0,0 +1,28 @@
+pv.SvgScene.bar = function(scenes) {
+  var e = scenes.$g.firstChild;
+  for (var i = 0; i < scenes.length; i++) {
+    var s = scenes[i];
+
+    /* visible */
+    if (!s.visible) continue;
+    var fill = s.fillStyle, stroke = s.strokeStyle;
+    if (!fill.opacity && !stroke.opacity) continue;
+
+    e = this.expect(e, "rect", {
+        "shape-rendering": s.antialias ? null : "crispEdges",
+        "pointer-events": s.events,
+        "cursor": s.cursor,
+        "x": s.left,
+        "y": s.top,
+        "width": Math.max(1E-10, s.width),
+        "height": Math.max(1E-10, s.height),
+        "fill": fill.color,
+        "fill-opacity": fill.opacity || null,
+        "stroke": stroke.color,
+        "stroke-opacity": stroke.opacity || null,
+        "stroke-width": stroke.opacity ? s.lineWidth / this.scale : null
+      });
+    e = this.append(e, scenes, i);
+  }
+  return e;
+};
diff --git a/vendor/protovis/src/scene/SvgCurve.js b/vendor/protovis/src/scene/SvgCurve.js
new file mode 100644
index 0000000..9013e13
--- /dev/null
+++ b/vendor/protovis/src/scene/SvgCurve.js
@@ -0,0 +1,354 @@
+/**
+ * @private Converts the specified b-spline curve segment to a bezier curve
+ * compatible with SVG "C".
+ *
+ * @param p0 the first control point.
+ * @param p1 the second control point.
+ * @param p2 the third control point.
+ * @param p3 the fourth control point.
+ */
+pv.SvgScene.pathBasis = (function() {
+
+  /**
+   * Matrix to transform basis (b-spline) control points to bezier control
+   * points. Derived from FvD 11.2.8.
+   */
+  var basis = [
+    [ 1/6, 2/3, 1/6,   0 ],
+    [   0, 2/3, 1/3,   0 ],
+    [   0, 1/3, 2/3,   0 ],
+    [   0, 1/6, 2/3, 1/6 ]
+  ];
+
+  /**
+   * Returns the point that is the weighted sum of the specified control points,
+   * using the specified weights. This method requires that there are four
+   * weights and four control points.
+   */
+  function weight(w, p0, p1, p2, p3) {
+    return {
+      x: w[0] * p0.left + w[1] * p1.left + w[2] * p2.left + w[3] * p3.left,
+      y: w[0] * p0.top  + w[1] * p1.top  + w[2] * p2.top  + w[3] * p3.top
+    };
+  }
+
+  var convert = function(p0, p1, p2, p3) {
+    var b1 = weight(basis[1], p0, p1, p2, p3),
+        b2 = weight(basis[2], p0, p1, p2, p3),
+        b3 = weight(basis[3], p0, p1, p2, p3);
+    return "C" + b1.x + "," + b1.y
+         + "," + b2.x + "," + b2.y
+         + "," + b3.x + "," + b3.y;
+  };
+
+  convert.segment = function(p0, p1, p2, p3) {
+    var b0 = weight(basis[0], p0, p1, p2, p3),
+        b1 = weight(basis[1], p0, p1, p2, p3),
+        b2 = weight(basis[2], p0, p1, p2, p3),
+        b3 = weight(basis[3], p0, p1, p2, p3);
+    return "M" + b0.x + "," + b0.y
+         + "C" + b1.x + "," + b1.y
+         + "," + b2.x + "," + b2.y
+         + "," + b3.x + "," + b3.y;
+  };
+
+  return convert;
+})();
+
+/**
+ * @private Interpolates the given points using the basis spline interpolation.
+ * Returns an SVG path without the leading M instruction to allow path
+ * appending.
+ *
+ * @param points the array of points.
+ */
+pv.SvgScene.curveBasis = function(points) {
+  if (points.length <= 2) return "";
+  var path = "",
+      p0 = points[0],
+      p1 = p0,
+      p2 = p0,
+      p3 = points[1];
+  path += this.pathBasis(p0, p1, p2, p3);
+  for (var i = 2; i < points.length; i++) {
+    p0 = p1;
+    p1 = p2;
+    p2 = p3;
+    p3 = points[i];
+    path += this.pathBasis(p0, p1, p2, p3);
+  }
+  /* Cycle through to get the last point. */
+  path += this.pathBasis(p1, p2, p3, p3);
+  path += this.pathBasis(p2, p3, p3, p3);
+  return path;
+};
+
+/**
+ * @private Interpolates the given points using the basis spline interpolation.
+ * If points.length == tangents.length then a regular Hermite interpolation is
+ * performed, if points.length == tangents.length + 2 then the first and last
+ * segments are filled in with cubic bazier segments.  Returns an array of path
+ * strings.
+ *
+ * @param points the array of points.
+ */
+pv.SvgScene.curveBasisSegments = function(points) {
+  if (points.length <= 2) return "";
+  var paths = [],
+      p0 = points[0],
+      p1 = p0,
+      p2 = p0,
+      p3 = points[1],
+      firstPath = this.pathBasis.segment(p0, p1, p2, p3);
+
+  p0 = p1;
+  p1 = p2;
+  p2 = p3;
+  p3 = points[2];
+  paths.push(firstPath + this.pathBasis(p0, p1, p2, p3)); // merge first & second path
+  for (var i = 3; i < points.length; i++) {
+    p0 = p1;
+    p1 = p2;
+    p2 = p3;
+    p3 = points[i];
+    paths.push(this.pathBasis.segment(p0, p1, p2, p3));
+  }
+
+  // merge last & second-to-last path
+  paths.push(this.pathBasis.segment(p1, p2, p3, p3) + this.pathBasis(p2, p3, p3, p3));
+  return paths;
+};
+
+/**
+ * @private Interpolates the given points with respective tangents using the cubic
+ * Hermite spline interpolation. If points.length == tangents.length then a regular
+ * Hermite interpolation is performed, if points.length == tangents.length + 2 then
+ * the first and last segments are filled in with cubic bazier segments.
+ * Returns an SVG path without the leading M instruction to allow path appending.
+ *
+ * @param points the array of points.
+ * @param tangents the array of tangent vectors.
+ */
+pv.SvgScene.curveHermite = function(points, tangents) {
+  if (tangents.length < 1
+      || (points.length != tangents.length
+      && points.length != tangents.length + 2)) return "";
+  var quad = points.length != tangents.length,
+      path = "",
+      p0 = points[0],
+      p = points[1],
+      t0 = tangents[0],
+      t = t0,
+      pi = 1;
+
+  if (quad) {
+    path += "Q" + (p.left - t0.x * 2 / 3) + ","  + (p.top - t0.y * 2 / 3)
+        + "," + p.left + "," + p.top;
+    p0 = points[1];
+    pi = 2;
+  }
+
+  if (tangents.length > 1) {
+    t = tangents[1];
+    p = points[pi];
+    pi++;
+    path += "C" + (p0.left + t0.x) + "," + (p0.top + t0.y)
+        + "," + (p.left - t.x) + "," + (p.top - t.y)
+        + "," + p.left + "," + p.top;
+    for (var i = 2; i < tangents.length; i++, pi++) {
+      p = points[pi];
+      t = tangents[i];
+      path += "S" + (p.left - t.x) + "," + (p.top - t.y)
+          + "," + p.left + "," + p.top;
+    }
+  }
+
+  if (quad) {
+    var lp = points[pi];
+    path += "Q" + (p.left + t.x * 2 / 3) + ","  + (p.top + t.y * 2 / 3) + ","
+        + lp.left + "," + lp.top;
+  }
+
+  return path;
+};
+
+/**
+ * @private Interpolates the given points with respective tangents using the
+ * cubic Hermite spline interpolation. Returns an array of path strings.
+ *
+ * @param points the array of points.
+ * @param tangents the array of tangent vectors.
+ */
+pv.SvgScene.curveHermiteSegments = function(points, tangents) {
+  if (tangents.length < 1
+      || (points.length != tangents.length
+      && points.length != tangents.length + 2)) return [];
+  var quad = points.length != tangents.length,
+      paths = [],
+      p0 = points[0],
+      p = p0,
+      t0 = tangents[0],
+      t = t0,
+      pi = 1;
+
+  if (quad) {
+    p = points[1];
+    paths.push("M" + p0.left + "," + p0.top
+        + "Q" + (p.left - t.x * 2 / 3) + "," + (p.top - t.y * 2 / 3)
+        + "," + p.left + "," + p.top);
+    pi = 2;
+  }
+
+  for (var i = 1; i < tangents.length; i++, pi++) {
+    p0 = p;
+    t0 = t;
+    p = points[pi];
+    t = tangents[i];
+    paths.push("M" + p0.left + "," + p0.top
+        + "C" + (p0.left + t0.x) + "," + (p0.top + t0.y)
+        + "," + (p.left - t.x) + "," + (p.top - t.y)
+        + "," + p.left + "," + p.top);
+  }
+
+  if (quad) {
+    var lp = points[pi];
+    paths.push("M" + p.left + "," + p.top
+        + "Q" + (p.left + t.x * 2 / 3) + ","  + (p.top + t.y * 2 / 3) + ","
+        + lp.left + "," + lp.top);
+  }
+
+  return paths;
+};
+
+/**
+ * @private Computes the tangents for the given points needed for cardinal
+ * spline interpolation. Returns an array of tangent vectors. Note: that for n
+ * points only the n-2 well defined tangents are returned.
+ *
+ * @param points the array of points.
+ * @param tension the tension of hte cardinal spline.
+ */
+pv.SvgScene.cardinalTangents = function(points, tension) {
+  var tangents = [],
+      a = (1 - tension) / 2,
+      p0 = points[0],
+      p1 = points[1],
+      p2 = points[2];
+
+  for (var i = 3; i < points.length; i++) {
+    tangents.push({x: a * (p2.left - p0.left), y: a * (p2.top - p0.top)});
+    p0 = p1;
+    p1 = p2;
+    p2 = points[i];
+  }
+
+  tangents.push({x: a * (p2.left - p0.left), y: a * (p2.top - p0.top)});
+  return tangents;
+};
+
+/**
+ * @private Interpolates the given points using cardinal spline interpolation.
+ * Returns an SVG path without the leading M instruction to allow path
+ * appending.
+ *
+ * @param points the array of points.
+ * @param tension the tension of hte cardinal spline.
+ */
+pv.SvgScene.curveCardinal = function(points, tension) {
+  if (points.length <= 2) return "";
+  return this.curveHermite(points, this.cardinalTangents(points, tension));
+};
+
+/**
+ * @private Interpolates the given points using cardinal spline interpolation.
+ * Returns an array of path strings.
+ *
+ * @param points the array of points.
+ * @param tension the tension of hte cardinal spline.
+ */
+pv.SvgScene.curveCardinalSegments = function(points, tension) {
+  if (points.length <= 2) return "";
+  return this.curveHermiteSegments(points, this.cardinalTangents(points, tension));
+};
+
+/**
+ * @private Interpolates the given points using Fritsch-Carlson Monotone cubic
+ * Hermite interpolation. Returns an array of tangent vectors.
+ *
+ * @param points the array of points.
+ */
+pv.SvgScene.monotoneTangents = function(points) {
+  var tangents = [],
+      d = [],
+      m = [],
+      dx = [],
+      k = 0;
+
+  /* Compute the slopes of the secant lines between successive points. */
+  for (k = 0; k < points.length-1; k++) {
+    d[k] = (points[k+1].top - points[k].top)/(points[k+1].left - points[k].left);
+  }
+
+  /* Initialize the tangents at every point as the average of the secants. */
+  m[0] = d[0];
+  dx[0] = points[1].left - points[0].left;
+  for (k = 1; k < points.length - 1; k++) {
+    m[k] = (d[k-1]+d[k])/2;
+    dx[k] = (points[k+1].left - points[k-1].left)/2;
+  }
+  m[k] = d[k-1];
+  dx[k] = (points[k].left - points[k-1].left);
+
+  /* Step 3. Very important, step 3. Yep. Wouldn't miss it. */
+  for (k = 0; k < points.length - 1; k++) {
+    if (d[k] == 0) {
+      m[ k ] = 0;
+      m[k+1] = 0;
+    }
+  }
+
+  /* Step 4 + 5. Out of 5 or more steps. */
+  for (k = 0; k < points.length - 1; k++) {
+    if ((Math.abs(m[k]) < 1e-5) || (Math.abs(m[k+1]) < 1e-5)) continue;
+    var ak = m[k] / d[k],
+        bk = m[k + 1] / d[k],
+        s = ak * ak + bk * bk; // monotone constant (?)
+    if (s > 9) {
+      var tk = 3 / Math.sqrt(s);
+      m[k] = tk * ak * d[k];
+      m[k + 1] = tk * bk * d[k];
+    }
+  }
+
+  var len;
+  for (var i = 0; i < points.length; i++) {
+    len = 1 + m[i] * m[i]; // pv.vector(1, m[i]).norm().times(dx[i]/3)
+    tangents.push({x: dx[i] / 3 / len, y: m[i] * dx[i] / 3 / len});
+  }
+
+  return tangents;
+};
+
+/**
+ * @private Interpolates the given points using Fritsch-Carlson Monotone cubic
+ * Hermite interpolation. Returns an SVG path without the leading M instruction
+ * to allow path appending.
+ *
+ * @param points the array of points.
+ */
+pv.SvgScene.curveMonotone = function(points) {
+  if (points.length <= 2) return "";
+  return this.curveHermite(points, this.monotoneTangents(points));
+}
+
+/**
+ * @private Interpolates the given points using Fritsch-Carlson Monotone cubic
+ * Hermite interpolation.
+ * Returns an array of path strings.
+ *
+ * @param points the array of points.
+ */
+pv.SvgScene.curveMonotoneSegments = function(points) {
+  if (points.length <= 2) return "";
+  return this.curveHermiteSegments(points, this.monotoneTangents(points));
+};
diff --git a/vendor/protovis/src/scene/SvgDot.js b/vendor/protovis/src/scene/SvgDot.js
new file mode 100644
index 0000000..7bc1a1a
--- /dev/null
+++ b/vendor/protovis/src/scene/SvgDot.js
@@ -0,0 +1,81 @@
+pv.SvgScene.dot = function(scenes) {
+  var e = scenes.$g.firstChild;
+  for (var i = 0; i < scenes.length; i++) {
+    var s = scenes[i];
+
+    /* visible */
+    if (!s.visible) continue;
+    var fill = s.fillStyle, stroke = s.strokeStyle;
+    if (!fill.opacity && !stroke.opacity) continue;
+
+    /* points */
+    var radius = s.shapeRadius, path = null;
+    switch (s.shape) {
+      case "cross": {
+        path = "M" + -radius + "," + -radius
+            + "L" + radius + "," + radius
+            + "M" + radius + "," + -radius
+            + "L" + -radius + "," + radius;
+        break;
+      }
+      case "triangle": {
+        var h = radius, w = radius * 1.1547; // 2 / Math.sqrt(3)
+        path = "M0," + h
+            + "L" + w +"," + -h
+            + " " + -w + "," + -h
+            + "Z";
+        break;
+      }
+      case "diamond": {
+        radius *= Math.SQRT2;
+        path = "M0," + -radius
+            + "L" + radius + ",0"
+            + " 0," + radius
+            + " " + -radius + ",0"
+            + "Z";
+        break;
+      }
+      case "square": {
+        path = "M" + -radius + "," + -radius
+            + "L" + radius + "," + -radius
+            + " " + radius + "," + radius
+            + " " + -radius + "," + radius
+            + "Z";
+        break;
+      }
+      case "tick": {
+        path = "M0,0L0," + -s.shapeSize;
+        break;
+      }
+      case "bar": {
+        path = "M0," + (s.shapeSize / 2) + "L0," + -(s.shapeSize / 2);
+        break;
+      }
+    }
+
+    /* Use <circle> for circles, <path> for everything else. */
+    var svg = {
+      "shape-rendering": s.antialias ? null : "crispEdges",
+      "pointer-events": s.events,
+      "cursor": s.cursor,
+      "fill": fill.color,
+      "fill-opacity": fill.opacity || null,
+      "stroke": stroke.color,
+      "stroke-opacity": stroke.opacity || null,
+      "stroke-width": stroke.opacity ? s.lineWidth / this.scale : null
+    };
+    if (path) {
+      svg.transform = "translate(" + s.left + "," + s.top + ")";
+      if (s.shapeAngle) svg.transform += " rotate(" + 180 * s.shapeAngle / Math.PI + ")";
+      svg.d = path;
+      e = this.expect(e, "path", svg);
+    } else {
+      svg.cx = s.left;
+      svg.cy = s.top;
+      svg.r = radius;
+      e = this.expect(e, "circle", svg);
+    }
+    e = this.append(e, scenes, i);
+  }
+  return e;
+};
diff --git a/vendor/protovis/src/scene/SvgImage.js b/vendor/protovis/src/scene/SvgImage.js
new file mode 100644
index 0000000..8863001
--- /dev/null
+++ b/vendor/protovis/src/scene/SvgImage.js
@@ -0,0 +1,45 @@
+pv.SvgScene.image = function(scenes) {
+  var e = scenes.$g.firstChild;
+  for (var i = 0; i < scenes.length; i++) {
+    var s = scenes[i];
+
+    /* visible */
+    if (!s.visible) continue;
+
+    /* fill */
+    e = this.fill(e, scenes, i);
+
+    /* image */
+    if (s.image) {
+      e = this.expect(e, "foreignObject", {
+          "cursor": s.cursor,
+          "x": s.left,
+          "y": s.top,
+          "width": s.width,
+          "height": s.height
+        });
+      var c = e.firstChild || e.appendChild(document.createElementNS(this.xhtml, "canvas"));
+      c.$scene = {scenes:scenes, index:i};
+      c.style.width = s.width;
+      c.style.height = s.height;
+      c.width = s.imageWidth;
+      c.height = s.imageHeight;
+      c.getContext("2d").putImageData(s.image, 0, 0);
+    } else {
+      e = this.expect(e, "image", {
+          "preserveAspectRatio": "none",
+          "cursor": s.cursor,
+          "x": s.left,
+          "y": s.top,
+          "width": s.width,
+          "height": s.height
+        });
+      e.setAttributeNS(this.xlink, "href", s.url);
+    }
+    e = this.append(e, scenes, i);
+
+    /* stroke */
+    e = this.stroke(e, scenes, i);
+  }
+  return e;
+};
diff --git a/vendor/protovis/src/scene/SvgLabel.js b/vendor/protovis/src/scene/SvgLabel.js
new file mode 100644
index 0000000..b39c99f
--- /dev/null
+++ b/vendor/protovis/src/scene/SvgLabel.js
@@ -0,0 +1,46 @@
+pv.SvgScene.label = function(scenes) {
+  var e = scenes.$g.firstChild;
+  for (var i = 0; i < scenes.length; i++) {
+    var s = scenes[i];
+
+    /* visible */
+    if (!s.visible) continue;
+    var fill = s.textStyle;
+    if (!fill.opacity || !s.text) continue;
+
+    /* text-baseline, text-align */
+    var x = 0, y = 0, dy = 0, anchor = "start";
+    switch (s.textBaseline) {
+      case "middle": dy = ".35em"; break;
+      case "top": dy = ".71em"; y = s.textMargin; break;
+      case "bottom": y = "-" + s.textMargin; break;
+    }
+    switch (s.textAlign) {
+      case "right": anchor = "end"; x = "-" + s.textMargin; break;
+      case "center": anchor = "middle"; break;
+      case "left": x = s.textMargin; break;
+    }
+
+    e = this.expect(e, "text", {
+        "pointer-events": s.events,
+        "cursor": s.cursor,
+        "x": x,
+        "y": y,
+        "dy": dy,
+        "transform": "translate(" + s.left + "," + s.top + ")"
+            + (s.textAngle ? " rotate(" + 180 * s.textAngle / Math.PI + ")" : "")
+            + (this.scale != 1 ? " scale(" + 1 / this.scale + ")" : ""),
+        "fill": fill.color,
+        "fill-opacity": fill.opacity || null,
+        "text-anchor": anchor
+      }, {
+        "font": s.font,
+        "text-shadow": s.textShadow,
+        "text-decoration": s.textDecoration
+      });
+    if (e.firstChild) e.firstChild.nodeValue = s.text;
+    else e.appendChild(document.createTextNode(s.text));
+    e = this.append(e, scenes, i);
+  }
+  return e;
+};
diff --git a/vendor/protovis/src/scene/SvgLine.js b/vendor/protovis/src/scene/SvgLine.js
new file mode 100644
index 0000000..e4f198e
--- /dev/null
+++ b/vendor/protovis/src/scene/SvgLine.js
@@ -0,0 +1,159 @@
+pv.SvgScene.line = function(scenes) {
+  var e = scenes.$g.firstChild;
+  if (scenes.length < 2) return e;
+  var s = scenes[0];
+
+  /* segmented */
+  if (s.segmented) return this.lineSegment(scenes);
+
+  /* visible */
+  if (!s.visible) return e;
+  var fill = s.fillStyle, stroke = s.strokeStyle;
+  if (!fill.opacity && !stroke.opacity) return e;
+
+  /* points */
+  var d = "M" + s.left + "," + s.top;
+
+  if (scenes.length > 2 && (s.interpolate == "basis" || s.interpolate == "cardinal" || s.interpolate == "monotone")) {
+    switch (s.interpolate) {
+      case "basis": d += this.curveBasis(scenes); break;
+      case "cardinal": d += this.curveCardinal(scenes, s.tension); break;
+      case "monotone": d += this.curveMonotone(scenes); break;
+    }
+  } else {
+    for (var i = 1; i < scenes.length; i++) {
+      d += this.pathSegment(scenes[i - 1], scenes[i]);
+    }
+  }
+
+  e = this.expect(e, "path", {
+      "shape-rendering": s.antialias ? null : "crispEdges",
+      "pointer-events": s.events,
+      "cursor": s.cursor,
+      "d": d,
+      "fill": fill.color,
+      "fill-opacity": fill.opacity || null,
+      "stroke": stroke.color,
+      "stroke-opacity": stroke.opacity || null,
+      "stroke-width": stroke.opacity ? s.lineWidth / this.scale : null,
+      "stroke-linejoin": s.lineJoin
+    });
+  return this.append(e, scenes, 0);
+};
+
+pv.SvgScene.lineSegment = function(scenes) {
+  var e = scenes.$g.firstChild;
+
+  var s = scenes[0];
+  var paths;
+  switch (s.interpolate) {
+    case "basis": paths = this.curveBasisSegments(scenes); break;
+    case "cardinal": paths = this.curveCardinalSegments(scenes, s.tension); break;
+    case "monotone": paths = this.curveMonotoneSegments(scenes); break;
+  }
+
+  for (var i = 0, n = scenes.length - 1; i < n; i++) {
+    var s1 = scenes[i], s2 = scenes[i + 1];
+
+    /* visible */
+    if (!s1.visible || !s2.visible) continue;
+    var stroke = s1.strokeStyle, fill = pv.Color.transparent;
+    if (!stroke.opacity) continue;
+
+    /* interpolate */
+    var d;
+    if ((s1.interpolate == "linear") && (s1.lineJoin == "miter")) {
+      fill = stroke;
+      stroke = pv.Color.transparent;
+      d = this.pathJoin(scenes[i - 1], s1, s2, scenes[i + 2]);
+    } else if(paths) {
+      d = paths[i];
+    } else {
+      d = "M" + s1.left + "," + s1.top + this.pathSegment(s1, s2);
+    }
+
+    e = this.expect(e, "path", {
+        "shape-rendering": s1.antialias ? null : "crispEdges",
+        "pointer-events": s1.events,
+        "cursor": s1.cursor,
+        "d": d,
+        "fill": fill.color,
+        "fill-opacity": fill.opacity || null,
+        "stroke": stroke.color,
+        "stroke-opacity": stroke.opacity || null,
+        "stroke-width": stroke.opacity ? s1.lineWidth / this.scale : null,
+        "stroke-linejoin": s1.lineJoin
+      });
+    e = this.append(e, scenes, i);
+  }
+  return e;
+};
+
+/** @private Returns the path segment for the specified points. */
+pv.SvgScene.pathSegment = function(s1, s2) {
+  var l = 1; // sweep-flag
+  switch (s1.interpolate) {
+    case "polar-reverse":
+      l = 0;
+    case "polar": {
+      var dx = s2.left - s1.left,
+          dy = s2.top - s1.top,
+          e = 1 - s1.eccentricity,
+          r = Math.sqrt(dx * dx + dy * dy) / (2 * e);
+      if ((e <= 0) || (e > 1)) break; // draw a straight line
+      return "A" + r + "," + r + " 0 0," + l + " " + s2.left + "," + s2.top;
+    }
+    case "step-before": return "V" + s2.top + "H" + s2.left;
+    case "step-after": return "H" + s2.left + "V" + s2.top;
+  }
+  return "L" + s2.left + "," + s2.top;
+};
+
+/** @private Line-line intersection, per Akenine-Moller 16.16.1. */
+pv.SvgScene.lineIntersect = function(o1, d1, o2, d2) {
+  return o1.plus(d1.times(o2.minus(o1).dot(d2.perp()) / d1.dot(d2.perp())));
+}
+
+/** @private Returns the miter join path for the specified points. */
+pv.SvgScene.pathJoin = function(s0, s1, s2, s3) {
+  /*
+   * P1-P2 is the current line segment. V is a vector that is perpendicular to
+   * the line segment, and has length lineWidth / 2. ABCD forms the initial
+   * bounding box of the line segment (i.e., the line segment if we were to do
+   * no joins).
+   */
+  var p1 = pv.vector(s1.left, s1.top),
+      p2 = pv.vector(s2.left, s2.top),
+      p = p2.minus(p1),
+      v = p.perp().norm(),
+      w = v.times(s1.lineWidth / (2 * this.scale)),
+      a = p1.plus(w),
+      b = p2.plus(w),
+      c = p2.minus(w),
+      d = p1.minus(w);
+
+  /*
+   * Start join. P0 is the previous line segment's start point. We define the
+   * cutting plane as the average of the vector perpendicular to P0-P1, and
+   * the vector perpendicular to P1-P2. This insures that the cross-section of
+   * the line on the cutting plane is equal if the line-width is unchanged.
+   * Note that we don't implement miter limits, so these can get wild.
+   */
+  if (s0 && s0.visible) {
+    var v1 = p1.minus(s0.left, s0.top).perp().norm().plus(v);
+    d = this.lineIntersect(p1, v1, d, p);
+    a = this.lineIntersect(p1, v1, a, p);
+  }
+
+  /* Similarly, for end join. */
+  if (s3 && s3.visible) {
+    var v2 = pv.vector(s3.left, s3.top).minus(p2).perp().norm().plus(v);
+    c = this.lineIntersect(p2, v2, c, p);
+    b = this.lineIntersect(p2, v2, b, p);
+  }
+
+  return "M" + a.x + "," + a.y
+       + "L" + b.x + "," + b.y
+       + " " + c.x + "," + c.y
+       + " " + d.x + "," + d.y;
+};
diff --git a/vendor/protovis/src/scene/SvgPanel.js b/vendor/protovis/src/scene/SvgPanel.js
new file mode 100644
index 0000000..45c5c0a
--- /dev/null
+++ b/vendor/protovis/src/scene/SvgPanel.js
@@ -0,0 +1,126 @@
+pv.SvgScene.panel = function(scenes) {
+  var g = scenes.$g, e = g && g.firstChild;
+  for (var i = 0; i < scenes.length; i++) {
+    var s = scenes[i];
+
+    /* visible */
+    if (!s.visible) continue;
+
+    /* svg */
+    if (!scenes.parent) {
+      s.canvas.style.display = "inline-block";
+      if (g && (g.parentNode != s.canvas)) {
+        g = s.canvas.firstChild;
+        e = g && g.firstChild;
+      }
+      if (!g) {
+        g = s.canvas.appendChild(this.create("svg"));
+        g.setAttribute("font-size", "10px");
+        g.setAttribute("font-family", "sans-serif");
+        g.setAttribute("fill", "none");
+        g.setAttribute("stroke", "none");
+        g.setAttribute("stroke-width", 1.5);
+        for (var j = 0; j < this.events.length; j++) {
+          g.addEventListener(this.events[j], this.dispatch, false);
+        }
+        e = g.firstChild;
+      }
+      scenes.$g = g;
+      g.setAttribute("width", s.width + s.left + s.right);
+      g.setAttribute("height", s.height + s.top + s.bottom);
+    }
+
+    /* clip (nest children) */
+    if (s.overflow == "hidden") {
+      var id = pv.id().toString(36),
+          c = this.expect(e, "g", {"clip-path": "url(#" + id + ")"});
+      if (!c.parentNode) g.appendChild(c);
+      scenes.$g = g = c;
+      e = c.firstChild;
+
+      e = this.expect(e, "clipPath", {"id": id});
+      var r = e.firstChild || e.appendChild(this.create("rect"));
+      r.setAttribute("x", s.left);
+      r.setAttribute("y", s.top);
+      r.setAttribute("width", s.width);
+      r.setAttribute("height", s.height);
+      if (!e.parentNode) g.appendChild(e);
+      e = e.nextSibling;
+    }
+
+    /* fill */
+    e = this.fill(e, scenes, i);
+
+    /* transform (push) */
+    var k = this.scale,
+        t = s.transform,
+        x = s.left + t.x,
+        y = s.top + t.y;
+    this.scale *= t.k;
+
+    /* children */
+    for (var j = 0; j < s.children.length; j++) {
+      s.children[j].$g = e = this.expect(e, "g", {
+          "transform": "translate(" + x + "," + y + ")"
+              + (t.k != 1 ? " scale(" + t.k + ")" : "")
+        });
+      this.updateAll(s.children[j]);
+      if (!e.parentNode) g.appendChild(e);
+      e = e.nextSibling;
+    }
+
+    /* transform (pop) */
+    this.scale = k;
+
+    /* stroke */
+    e = this.stroke(e, scenes, i);
+
+    /* clip (restore group) */
+    if (s.overflow == "hidden") {
+      scenes.$g = g = c.parentNode;
+      e = c.nextSibling;
+    }
+  }
+  return e;
+};
+
+pv.SvgScene.fill = function(e, scenes, i) {
+  var s = scenes[i], fill = s.fillStyle;
+  if (fill.opacity || s.events == "all") {
+    e = this.expect(e, "rect", {
+        "shape-rendering": s.antialias ? null : "crispEdges",
+        "pointer-events": s.events,
+        "cursor": s.cursor,
+        "x": s.left,
+        "y": s.top,
+        "width": s.width,
+        "height": s.height,
+        "fill": fill.color,
+        "fill-opacity": fill.opacity,
+        "stroke": null
+      });
+    e = this.append(e, scenes, i);
+  }
+  return e;
+};
+
+pv.SvgScene.stroke = function(e, scenes, i) {
+  var s = scenes[i], stroke = s.strokeStyle;
+  if (stroke.opacity || s.events == "all") {
+    e = this.expect(e, "rect", {
+        "shape-rendering": s.antialias ? null : "crispEdges",
+        "pointer-events": s.events == "all" ? "stroke" : s.events,
+        "cursor": s.cursor,
+        "x": s.left,
+        "y": s.top,
+        "width": Math.max(1E-10, s.width),
+        "height": Math.max(1E-10, s.height),
+        "fill": null,
+        "stroke": stroke.color,
+        "stroke-opacity": stroke.opacity,
+        "stroke-width": s.lineWidth / this.scale
+      });
+    e = this.append(e, scenes, i);
+  }
+  return e;
+};
diff --git a/vendor/protovis/src/scene/SvgRule.js b/vendor/protovis/src/scene/SvgRule.js
new file mode 100644
index 0000000..98fc798
--- /dev/null
+++ b/vendor/protovis/src/scene/SvgRule.js
@@ -0,0 +1,26 @@
+pv.SvgScene.rule = function(scenes) {
+  var e = scenes.$g.firstChild;
+  for (var i = 0; i < scenes.length; i++) {
+    var s = scenes[i];
+
+    /* visible */
+    if (!s.visible) continue;
+    var stroke = s.strokeStyle;
+    if (!stroke.opacity) continue;
+
+    e = this.expect(e, "line", {
+        "shape-rendering": s.antialias ? null : "crispEdges",
+        "pointer-events": s.events,
+        "cursor": s.cursor,
+        "x1": s.left,
+        "y1": s.top,
+        "x2": s.left + s.width,
+        "y2": s.top + s.height,
+        "stroke": stroke.color,
+        "stroke-opacity": stroke.opacity,
+        "stroke-width": s.lineWidth / this.scale
+      });
+    e = this.append(e, scenes, i);
+  }
+  return e;
+};
diff --git a/vendor/protovis/src/scene/SvgScene.js b/vendor/protovis/src/scene/SvgScene.js
new file mode 100644
index 0000000..177c51a
--- /dev/null
+++ b/vendor/protovis/src/scene/SvgScene.js
@@ -0,0 +1,185 @@
+/**
+ * @private
+ * @namespace
+ */
+pv.Scene = pv.SvgScene = {
+  /* Various namespaces. */
+  svg: "http://www.w3.org/2000/svg",
+  xmlns: "http://www.w3.org/2000/xmlns",
+  xlink: "http://www.w3.org/1999/xlink",
+  xhtml: "http://www.w3.org/1999/xhtml",
+
+  /** The pre-multipled scale, based on any enclosing transforms. */
+  scale: 1,
+
+  /** The set of supported events. */
+  events: [
+    "DOMMouseScroll", // for Firefox
+    "mousewheel",
+    "mousedown",
+    "mouseup",
+    "mouseover",
+    "mouseout",
+    "mousemove",
+    "click",
+    "dblclick"
+  ],
+
+  /** Implicit values for SVG and CSS properties. */
+  implicit: {
+    svg: {
+      "shape-rendering": "auto",
+      "pointer-events": "painted",
+      "x": 0,
+      "y": 0,
+      "dy": 0,
+      "text-anchor": "start",
+      "transform": "translate(0,0)",
+      "fill": "none",
+      "fill-opacity": 1,
+      "stroke": "none",
+      "stroke-opacity": 1,
+      "stroke-width": 1.5,
+      "stroke-linejoin": "miter"
+    },
+    css: {
+      "font": "10px sans-serif"
+    }
+  }
+};
+
+/**
+ * Updates the display for the specified array of scene nodes.
+ *
+ * @param scenes {array} an array of scene nodes.
+ */
+pv.SvgScene.updateAll = function(scenes) {
+  if (scenes.length
+      && scenes[0].reverse
+      && (scenes.type != "line")
+      && (scenes.type != "area")) {
+    var reversed = pv.extend(scenes);
+    for (var i = 0, j = scenes.length - 1; j >= 0; i++, j--) {
+      reversed[i] = scenes[j];
+    }
+    scenes = reversed;
+  }
+  this.removeSiblings(this[scenes.type](scenes));
+};
+
+/**
+ * Creates a new SVG element of the specified type.
+ *
+ * @param type {string} an SVG element type, such as "rect".
+ * @returns a new SVG element.
+ */
+pv.SvgScene.create = function(type) {
+  return document.createElementNS(this.svg, type);
+};
+
+/**
+ * Expects the element <i>e</i> to be the specified type. If the element does
+ * not exist, a new one is created. If the element does exist but is the wrong
+ * type, it is replaced with the specified element.
+ *
+ * @param e the current SVG element.
+ * @param type {string} an SVG element type, such as "rect".
+ * @param attributes an optional attribute map.
+ * @param style an optional style map.
+ * @returns a new SVG element.
+ */
+pv.SvgScene.expect = function(e, type, attributes, style) {
+  if (e) {
+    if (e.tagName == "a") e = e.firstChild;
+    if (e.tagName != type) {
+      var n = this.create(type);
+      e.parentNode.replaceChild(n, e);
+      e = n;
+    }
+  } else {
+    e = this.create(type);
+  }
+  for (var name in attributes) {
+    var value = attributes[name];
+    if (value == this.implicit.svg[name]) value = null;
+    if (value == null) e.removeAttribute(name);
+    else e.setAttribute(name, value);
+  }
+  for (var name in style) {
+    var value = style[name];
+    if (value == this.implicit.css[name]) value = null;
+    if (value == null) e.style.removeProperty(name);
+    else e.style[name] = value;
+  }
+  return e;
+};
+
+/** TODO */
+pv.SvgScene.append = function(e, scenes, index) {
+  e.$scene = {scenes:scenes, index:index};
+  e = this.title(e, scenes[index]);
+  if (!e.parentNode) scenes.$g.appendChild(e);
+  return e.nextSibling;
+};
+
+/**
+ * Applies a title tooltip to the specified element <tt>e</tt>, using the
+ * <tt>title</tt> property of the specified scene node <tt>s</tt>. Note that
+ * this implementation does not create an SVG <tt>title</tt> element as a child
+ * of <tt>e</tt>; although this is the recommended standard, it is only
+ * supported in Opera. Instead, an anchor element is created around the element
+ * <tt>e</tt>, and the <tt>xlink:title</tt> attribute is set accordingly.
+ *
+ * @param e an SVG element.
+ * @param s a scene node.
+ */
+pv.SvgScene.title = function(e, s) {
+  var a = e.parentNode;
+  if (a && (a.tagName != "a")) a = null;
+  if (s.title) {
+    if (!a) {
+      a = this.create("a");
+      if (e.parentNode) e.parentNode.replaceChild(a, e);
+      a.appendChild(e);
+    }
+    a.setAttributeNS(this.xlink, "title", s.title);
+    return a;
+  }
+  if (a) a.parentNode.replaceChild(e, a);
+  return e;
+};
+
+/** TODO */
+pv.SvgScene.dispatch = pv.listener(function(e) {
+  var t = e.target.$scene;
+  if (t) {
+    var type = e.type;
+
+    /* Fixes for mousewheel support on Firefox & Opera. */
+    switch (type) {
+      case "DOMMouseScroll": {
+        type = "mousewheel";
+        e.wheel = -480 * e.detail;
+        break;
+      }
+      case "mousewheel": {
+        e.wheel = (window.opera ? 12 : 1) * e.wheelDelta;
+        break;
+      }
+    }
+
+    if (pv.Mark.dispatch(type, t.scenes, t.index)) e.preventDefault();
+  }
+});
+
+/** @private Remove siblings following element <i>e</i>. */
+pv.SvgScene.removeSiblings = function(e) {
+  while (e) {
+    var n = e.nextSibling;
+    e.parentNode.removeChild(e);
+    e = n;
+  }
+};
+
+/** @private Do nothing when rendering undefined mark types. */
+pv.SvgScene.undefined = function() {};
diff --git a/vendor/protovis/src/scene/SvgWedge.js b/vendor/protovis/src/scene/SvgWedge.js
new file mode 100644
index 0000000..d8ed9a8
--- /dev/null
+++ b/vendor/protovis/src/scene/SvgWedge.js
@@ -0,0 +1,66 @@
+pv.SvgScene.wedge = function(scenes) {
+  var e = scenes.$g.firstChild;
+  for (var i = 0; i < scenes.length; i++) {
+    var s = scenes[i];
+
+    /* visible */
+    if (!s.visible) continue;
+    var fill = s.fillStyle, stroke = s.strokeStyle;
+    if (!fill.opacity && !stroke.opacity) continue;
+
+    /* points */
+    var r1 = s.innerRadius, r2 = s.outerRadius, a = Math.abs(s.angle), p;
+    if (a >= 2 * Math.PI) {
+      if (r1) {
+        p = "M0," + r2
+            + "A" + r2 + "," + r2 + " 0 1,1 0," + (-r2)
+            + "A" + r2 + "," + r2 + " 0 1,1 0," + r2
+            + "M0," + r1
+            + "A" + r1 + "," + r1 + " 0 1,1 0," + (-r1)
+            + "A" + r1 + "," + r1 + " 0 1,1 0," + r1
+            + "Z";
+      } else {
+        p = "M0," + r2
+            + "A" + r2 + "," + r2 + " 0 1,1 0," + (-r2)
+            + "A" + r2 + "," + r2 + " 0 1,1 0," + r2
+            + "Z";
+      }
+    } else {
+      var sa = Math.min(s.startAngle, s.endAngle),
+          ea = Math.max(s.startAngle, s.endAngle),
+          c1 = Math.cos(sa), c2 = Math.cos(ea),
+          s1 = Math.sin(sa), s2 = Math.sin(ea);
+      if (r1) {
+        p = "M" + r2 * c1 + "," + r2 * s1
+            + "A" + r2 + "," + r2 + " 0 "
+            + ((a < Math.PI) ? "0" : "1") + ",1 "
+            + r2 * c2 + "," + r2 * s2
+            + "L" + r1 * c2 + "," + r1 * s2
+            + "A" + r1 + "," + r1 + " 0 "
+            + ((a < Math.PI) ? "0" : "1") + ",0 "
+            + r1 * c1 + "," + r1 * s1 + "Z";
+      } else {
+        p = "M" + r2 * c1 + "," + r2 * s1
+            + "A" + r2 + "," + r2 + " 0 "
+            + ((a < Math.PI) ? "0" : "1") + ",1 "
+            + r2 * c2 + "," + r2 * s2 + "L0,0Z";
+      }
+    }
+
+    e = this.expect(e, "path", {
+        "shape-rendering": s.antialias ? null : "crispEdges",
+        "pointer-events": s.events,
+        "cursor": s.cursor,
+        "transform": "translate(" + s.left + "," + s.top + ")",
+        "d": p,
+        "fill": fill.color,
+        "fill-rule": "evenodd",
+        "fill-opacity": fill.opacity || null,
+        "stroke": stroke.color,
+        "stroke-opacity": stroke.opacity || null,
+        "stroke-width": stroke.opacity ? s.lineWidth / this.scale : null
+      });
+    e = this.append(e, scenes, i);
+  }
+  return e;
+};
diff --git a/vendor/protovis/src/text/DateFormat.js b/vendor/protovis/src/text/DateFormat.js
new file mode 100644
index 0000000..5a3851e
--- /dev/null
+++ b/vendor/protovis/src/text/DateFormat.js
@@ -0,0 +1,262 @@
+/**
+ * Constructs a new date format with the specified string pattern.
+ *
+ * @class The format string is in the same format expected by the
+ * <tt>strftime</tt> function in C. The following conversion specifications are
+ * supported:<ul>
+ *
+ * <li>%a - abbreviated weekday name.</li>
+ * <li>%A - full weekday name.</li>
+ * <li>%b - abbreviated month names.</li>
+ * <li>%B - full month names.</li>
+ * <li>%c - locale's appropriate date and time.</li>
+ * <li>%C - century number.</li>
+ * <li>%d - day of month [01,31] (zero padded).</li>
+ * <li>%D - same as %m/%d/%y.</li>
+ * <li>%e - day of month [ 1,31] (space padded).</li>
+ * <li>%h - same as %b.</li>
+ * <li>%H - hour (24-hour clock) [00,23] (zero padded).</li>
+ * <li>%I - hour (12-hour clock) [01,12] (zero padded).</li>
+ * <li>%m - month number [01,12] (zero padded).</li>
+ * <li>%M - minute [0,59] (zero padded).</li>
+ * <li>%n - newline character.</li>
+ * <li>%p - locale's equivalent of a.m. or p.m.</li>
+ * <li>%r - same as %I:%M:%S %p.</li>
+ * <li>%R - same as %H:%M.</li>
+ * <li>%S - second [00,61] (zero padded).</li>
+ * <li>%t - tab character.</li>
+ * <li>%T - same as %H:%M:%S.</li>
+ * <li>%x - same as %m/%d/%y.</li>
+ * <li>%X - same as %I:%M:%S %p.</li>
+ * <li>%y - year with century [00,99] (zero padded).</li>
+ * <li>%Y - year including century.</li>
+ * <li>%% - %.</li>
+ *
+ * </ul>The following conversion specifications are currently <i>unsupported</i>
+ * for formatting:<ul>
+ *
+ * <li>%j - day number [1,366].</li>
+ * <li>%u - weekday number [1,7].</li>
+ * <li>%U - week number [00,53].</li>
+ * <li>%V - week number [01,53].</li>
+ * <li>%w - weekday number [0,6].</li>
+ * <li>%W - week number [00,53].</li>
+ * <li>%Z - timezone name or abbreviation.</li>
+ *
+ * </ul>In addition, the following conversion specifications are currently
+ * <i>unsupported</i> for parsing:<ul>
+ *
+ * <li>%a - day of week, either abbreviated or full name.</li>
+ * <li>%A - same as %a.</li>
+ * <li>%c - locale's appropriate date and time.</li>
+ * <li>%C - century number.</li>
+ * <li>%D - same as %m/%d/%y.</li>
+ * <li>%I - hour (12-hour clock) [1,12].</li>
+ * <li>%n - any white space.</li>
+ * <li>%p - locale's equivalent of a.m. or p.m.</li>
+ * <li>%r - same as %I:%M:%S %p.</li>
+ * <li>%R - same as %H:%M.</li>
+ * <li>%t - same as %n.</li>
+ * <li>%T - same as %H:%M:%S.</li>
+ * <li>%x - locale's equivalent to %m/%d/%y.</li>
+ * <li>%X - locale's equivalent to %I:%M:%S %p.</li>
+ *
+ * </ul>
+ *
+ * @see <a
+ * href="http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html">strftime</a>
+ * documentation.
+ * @see <a
+ * href="http://www.opengroup.org/onlinepubs/007908799/xsh/strptime.html">strptime</a>
+ * documentation.
+ * @extends pv.Format
+ * @param {string} pattern the format pattern.
+ */
+pv.Format.date = function(pattern) {
+  var pad = pv.Format.pad;
+
+  /** @private */
+  function format(d) {
+    return pattern.replace(/%[a-zA-Z0-9]/g, function(s) {
+        switch (s) {
+          case '%a': return [
+              "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+            ][d.getDay()];
+          case '%A': return [
+              "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
+              "Saturday"
+            ][d.getDay()];
+          case '%h':
+          case '%b': return [
+              "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
+              "Oct", "Nov", "Dec"
+            ][d.getMonth()];
+          case '%B': return [
+              "January", "February", "March", "April", "May", "June", "July",
+              "August", "September", "October", "November", "December"
+            ][d.getMonth()];
+          case '%c': return d.toLocaleString();
+          case '%C': return pad("0", 2, Math.floor(d.getFullYear() / 100) % 100);
+          case '%d': return pad("0", 2, d.getDate());
+          case '%x':
+          case '%D': return pad("0", 2, d.getMonth() + 1)
+                    + "/" + pad("0", 2, d.getDate())
+                    + "/" + pad("0", 2, d.getFullYear() % 100);
+          case '%e': return pad(" ", 2, d.getDate());
+          case '%H': return pad("0", 2, d.getHours());
+          case '%I': {
+            var h = d.getHours() % 12;
+            return h ? pad("0", 2, h) : 12;
+          }
+          // TODO %j: day of year as a decimal number [001,366]
+          case '%m': return pad("0", 2, d.getMonth() + 1);
+          case '%M': return pad("0", 2, d.getMinutes());
+          case '%n': return "\n";
+          case '%p': return d.getHours() < 12 ? "AM" : "PM";
+          case '%T':
+          case '%X':
+          case '%r': {
+            var h = d.getHours() % 12;
+            return (h ? pad("0", 2, h) : 12)
+                    + ":" + pad("0", 2, d.getMinutes())
+                    + ":" + pad("0", 2, d.getSeconds())
+                    + " " + (d.getHours() < 12 ? "AM" : "PM");
+          }
+          case '%R': return pad("0", 2, d.getHours()) + ":" + pad("0", 2, d.getMinutes());
+          case '%S': return pad("0", 2, d.getSeconds());
+          case '%Q': return pad("0", 3, d.getMilliseconds());
+          case '%t': return "\t";
+          case '%u': {
+            var w = d.getDay();
+            return w ? w : 1;
+          }
+          // TODO %U: week number (sunday first day) [00,53]
+          // TODO %V: week number (monday first day) [01,53] ... with weirdness
+          case '%w': return d.getDay();
+          // TODO %W: week number (monday first day) [00,53] ... with weirdness
+          case '%y': return pad("0", 2, d.getFullYear() % 100);
+          case '%Y': return d.getFullYear();
+          // TODO %Z: timezone name or abbreviation
+          case '%%': return "%";
+        }
+        return s;
+      });
+  }
+
+  /**
+   * Converts a date to a string using the associated formatting pattern.
+   *
+   * @function
+   * @name pv.Format.date.prototype.format
+   * @param {Date} date a date to format.
+   * @returns {string} the formatted date as a string.
+   */
+  format.format = format;
+
+  /**
+   * Parses a date from a string using the associated formatting pattern.
+   *
+   * @function
+   * @name pv.Format.date.prototype.parse
+   * @param {string} s the string to parse as a date.
+   * @returns {Date} the parsed date.
+   */
+  format.parse = function(s) {
+    var year = 1970, month = 0, date = 1, hour = 0, minute = 0, second = 0;
+    var fields = [function() {}];
+
+    /* Register callbacks for each field in the format pattern. */
+    var re = pv.Format.re(pattern).replace(/%[a-zA-Z0-9]/g, function(s) {
+        switch (s) {
+          // TODO %a: day of week, either abbreviated or full name
+          // TODO %A: same as %a
+          case '%b': {
+            fields.push(function(x) { month = {
+                  Jan: 0, Feb: 1, Mar: 2, Apr: 3, May: 4, Jun: 5, Jul: 6, Aug: 7,
+                  Sep: 8, Oct: 9, Nov: 10, Dec: 11
+                }[x]; });
+            return "([A-Za-z]+)";
+          }
+          case '%h':
+          case '%B': {
+            fields.push(function(x) { month = {
+                  January: 0, February: 1, March: 2, April: 3, May: 4, June: 5,
+                  July: 6, August: 7, September: 8, October: 9, November: 10,
+                  December: 11
+                }[x]; });
+            return "([A-Za-z]+)";
+          }
+          // TODO %c: locale's appropriate date and time
+          // TODO %C: century number[0,99]
+          case '%e':
+          case '%d': {
+            fields.push(function(x) { date = x; });
+            return "([0-9]+)";
+          }
+          // TODO %D: same as %m/%d/%y
+          case '%I':
+          case '%H': {
+            fields.push(function(x) { hour = x; });
+            return "([0-9]+)";
+          }
+          // TODO %j: day number [1,366]
+          case '%m': {
+            fields.push(function(x) { month = x - 1; });
+            return "([0-9]+)";
+          }
+          case '%M': {
+            fields.push(function(x) { minute = x; });
+            return "([0-9]+)";
+          }
+          // TODO %n: any white space
+          // TODO %p: locale's equivalent of a.m. or p.m.
+          case '%p': { // TODO this is a hack
+            fields.push(function(x) {
+              if (hour == 12) {
+                if (x == "am") hour = 0;
+              } else if (x == "pm") {
+                hour = Number(hour) + 12;
+              }
+            });
+            return "(am|pm)";
+          }
+          // TODO %r: %I:%M:%S %p
+          // TODO %R: %H:%M
+          case '%S': {
+            fields.push(function(x) { second = x; });
+            return "([0-9]+)";
+          }
+          // TODO %t: any white space
+          // TODO %T: %H:%M:%S
+          // TODO %U: week number [00,53]
+          // TODO %w: weekday [0,6]
+          // TODO %W: week number [00, 53]
+          // TODO %x: locale date (%m/%d/%y)
+          // TODO %X: locale time (%I:%M:%S %p)
+          case '%y': {
+            fields.push(function(x) {
+                x = Number(x);
+                year = x + (((0 <= x) && (x < 69)) ? 2000
+                    : (((x >= 69) && (x < 100) ? 1900 : 0)));
+              });
+            return "([0-9]+)";
+          }
+          case '%Y': {
+            fields.push(function(x) { year = x; });
+            return "([0-9]+)";
+          }
+          case '%%': {
+            fields.push(function() {});
+            return "%";
+          }
+        }
+        return s;
+      });
+
+    var match = s.match(re);
+    if (match) match.forEach(function(m, i) { fields[i](m); });
+    return new Date(year, month, date, hour, minute, second);
+  };
+
+  return format;
+};
diff --git a/vendor/protovis/src/text/Format.js b/vendor/protovis/src/text/Format.js
new file mode 100644
index 0000000..dadee4a
--- /dev/null
+++ b/vendor/protovis/src/text/Format.js
@@ -0,0 +1,78 @@
+/**
+ * Abstract; see an implementing class.
+ *
+ * @class Represents an abstract text formatter and parser. A <i>format</i> is a
+ * function that converts an object of a given type, such as a <tt>Date</tt>, to
+ * a human-readable string representation. The format may also have a
+ * {@link #parse} method for converting a string representation back to the
+ * given object type.
+ *
+ * <p>Because formats are themselves functions, they can be used directly as
+ * mark properties. For example, if the data associated with a label are dates,
+ * a date format can be used as label text:
+ *
+ * <pre>    .text(pv.Format.date("%m/%d/%y"))</pre>
+ *
+ * And as with scales, if the format is used in multiple places, it can be
+ * convenient to declare it as a global variable and then reference it from the
+ * appropriate property functions. For example, if the data has a <tt>date</tt>
+ * attribute, and <tt>format</tt> references a given date format:
+ *
+ * <pre>    .text(function(d) format(d.date))</pre>
+ *
+ * Similarly, to parse a string into a date:
+ *
+ * <pre>var date = format.parse("4/30/2010");</pre>
+ *
+ * Not all format implementations support parsing. See the implementing class
+ * for details.
+ *
+ * @see pv.Format.date
+ * @see pv.Format.number
+ * @see pv.Format.time
+ */
+pv.Format = {};
+
+/**
+ * Formats the specified object, returning the string representation.
+ *
+ * @function
+ * @name pv.Format.prototype.format
+ * @param {object} x the object to format.
+ * @returns {string} the formatted string.
+ */
+
+/**
+ * Parses the specified string, returning the object representation.
+ *
+ * @function
+ * @name pv.Format.prototype.parse
+ * @param {string} x the string to parse.
+ * @returns {object} the parsed object.
+ */
+
+/**
+ * @private Given a string that may be used as part of a regular expression,
+ * this methods returns an appropriately quoted version of the specified string,
+ * with any special characters escaped.
+ *
+ * @param {string} s a string to quote.
+ * @returns {string} the quoted string.
+ */
+pv.Format.re = function(s) {
+  return s.replace(/[\\\^\$\*\+\?\[\]\(\)\.\{\}]/g, "\\$&");
+};
+
+/**
+ * @private Optionally pads the specified string <i>s</i> so that it is at least
+ * <i>n</i> characters long, using the padding character <i>c</i>.
+ *
+ * @param {string} c the padding character.
+ * @param {number} n the minimum string length.
+ * @param {string} s the string to pad.
+ * @returns {string} the padded string.
+ */
+pv.Format.pad = function(c, n, s) {
+  var m = n - String(s).length;
+  return (m < 1) ? s : new Array(m + 1).join(c) + s;
+};
diff --git a/vendor/protovis/src/text/NumberFormat.js b/vendor/protovis/src/text/NumberFormat.js
new file mode 100644
index 0000000..863d2c0
--- /dev/null
+++ b/vendor/protovis/src/text/NumberFormat.js
@@ -0,0 +1,227 @@
+/**
+ * Returns a default number format.
+ *
+ * @class Represents a number format, converting between a <tt>number</tt> and a
+ * <tt>string</tt>. This class allows numbers to be formatted with variable
+ * precision (both for the integral and fractional part of the number), optional
+ * thousands grouping, and optional padding. The thousands (",") and decimal
+ * (".") separator can be customized.
+ *
+ * @returns {pv.Format.number} a number format.
+ */
+pv.Format.number = function() {
+  var mini = 0, // default minimum integer digits
+      maxi = Infinity, // default maximum integer digits
+      mins = 0, // mini, including group separators
+      minf = 0, // default minimum fraction digits
+      maxf = 0, // default maximum fraction digits
+      maxk = 1, // 10^maxf
+      padi = "0", // default integer pad
+      padf = "0", // default fraction pad
+      padg = true, // whether group separator affects integer padding
+      decimal = ".", // default decimal separator
+      group = ",", // default group separator
+      np = "\u2212", // default negative prefix
+      ns = ""; // default negative suffix
+
+  /** @private */
+  function format(x) {
+    /* Round the fractional part, and split on decimal separator. */
+    if (Infinity > maxf) x = Math.round(x * maxk) / maxk;
+    var s = String(Math.abs(x)).split(".");
+
+    /* Pad, truncate and group the integral part. */
+    var i = s[0];
+    if (i.length > maxi) i = i.substring(i.length - maxi);
+    if (padg && (i.length < mini)) i = new Array(mini - i.length + 1).join(padi) + i;
+    if (i.length > 3) i = i.replace(/\B(?=(?:\d{3})+(?!\d))/g, group);
+    if (!padg && (i.length < mins)) i = new Array(mins - i.length + 1).join(padi) + i;
+    s[0] = x < 0 ? np + i + ns : i;
+
+    /* Pad the fractional part. */
+    var f = s[1] || "";
+    if (f.length < minf) s[1] = f + new Array(minf - f.length + 1).join(padf);
+
+    return s.join(decimal);
+  }
+
+  /**
+   * @function
+   * @name pv.Format.number.prototype.format
+   * @param {number} x
+   * @returns {string}
+   */
+  format.format = format;
+
+  /**
+   * Parses the specified string as a number. Before parsing, leading and
+   * trailing padding is removed. Group separators are also removed, and the
+   * decimal separator is replaced with the standard point ("."). The integer
+   * part is truncated per the maximum integer digits, and the fraction part is
+   * rounded per the maximum fraction digits.
+   *
+   * @function
+   * @name pv.Format.number.prototype.parse
+   * @param {string} x the string to parse.
+   * @returns {number} the parsed number.
+   */
+  format.parse = function(x) {
+    var re = pv.Format.re;
+
+    /* Remove leading and trailing padding. Split on the decimal separator. */
+    var s = String(x)
+        .replace(new RegExp("^(" + re(padi) + ")*"), "")
+        .replace(new RegExp("(" + re(padf) + ")*$"), "")
+        .split(decimal);
+
+    /* Remove grouping and truncate the integral part. */
+    var i = s[0].replace(new RegExp(re(group), "g"), "");
+    if (i.length > maxi) i = i.substring(i.length - maxi);
+
+    /* Round the fractional part. */
+    var f = s[1] ? Number("0." + s[1]) : 0;
+    if (Infinity > maxf) f = Math.round(f * maxk) / maxk;
+
+    return Math.round(i) + f;
+  };
+
+  /**
+   * Sets or gets the minimum and maximum number of integer digits. This
+   * controls the number of decimal digits to display before the decimal
+   * separator for the integral part of the number. If the number of digits is
+   * smaller than the minimum, the digits are padded; if the number of digits is
+   * larger, the digits are truncated, showing only the lower-order digits. The
+   * default range is [0, Infinity].
+   *
+   * <p>If only one argument is specified to this method, this value is used as
+   * both the minimum and maximum number. If no arguments are specified, a
+   * two-element array is returned containing the minimum and the maximum.
+   *
+   * @function
+   * @name pv.Format.number.prototype.integerDigits
+   * @param {number} [min] the minimum integer digits.
+   * @param {number} [max] the maximum integer digits.
+   * @returns {pv.Format.number} <tt>this</tt>, or the current integer digits.
+   */
+  format.integerDigits = function(min, max) {
+    if (arguments.length) {
+      mini = Number(min);
+      maxi = (arguments.length > 1) ? Number(max) : mini;
+      mins = mini + Math.floor(mini / 3) * group.length;
+      return this;
+    }
+    return [mini, maxi];
+  };
+
+  /**
+   * Sets or gets the minimum and maximum number of fraction digits. The
+   * controls the number of decimal digits to display after the decimal
+   * separator for the fractional part of the number. If the number of digits is
+   * smaller than the minimum, the digits are padded; if the number of digits is
+   * larger, the fractional part is rounded, showing only the higher-order
+   * digits. The default range is [0, 0].
+   *
+   * <p>If only one argument is specified to this method, this value is used as
+   * both the minimum and maximum number. If no arguments are specified, a
+   * two-element array is returned containing the minimum and the maximum.
+   *
+   * @function
+   * @name pv.Format.number.prototype.fractionDigits
+   * @param {number} [min] the minimum fraction digits.
+   * @param {number} [max] the maximum fraction digits.
+   * @returns {pv.Format.number} <tt>this</tt>, or the current fraction digits.
+   */
+  format.fractionDigits = function(min, max) {
+    if (arguments.length) {
+      minf = Number(min);
+      maxf = (arguments.length > 1) ? Number(max) : minf;
+      maxk = Math.pow(10, maxf);
+      return this;
+    }
+    return [minf, maxf];
+  };
+
+  /**
+   * Sets or gets the character used to pad the integer part. The integer pad is
+   * used when the number of integer digits is smaller than the minimum. The
+   * default pad character is "0" (zero).
+   *
+   * @param {string} [x] the new pad character.
+   * @returns {pv.Format.number} <tt>this</tt> or the current pad character.
+   */
+  format.integerPad = function(x) {
+    if (arguments.length) {
+      padi = String(x);
+      padg = /\d/.test(padi);
+      return this;
+    }
+    return padi;
+  };
+
+  /**
+   * Sets or gets the character used to pad the fration part. The fraction pad
+   * is used when the number of fraction digits is smaller than the minimum. The
+   * default pad character is "0" (zero).
+   *
+   * @param {string} [x] the new pad character.
+   * @returns {pv.Format.number} <tt>this</tt> or the current pad character.
+   */
+  format.fractionPad = function(x) {
+    if (arguments.length) {
+      padf = String(x);
+      return this;
+    }
+    return padf;
+  };
+
+  /**
+   * Sets or gets the character used as the decimal point, separating the
+   * integer and fraction parts of the number. The default decimal point is ".".
+   *
+   * @param {string} [x] the new decimal separator.
+   * @returns {pv.Format.number} <tt>this</tt> or the current decimal separator.
+   */
+  format.decimal = function(x) {
+    if (arguments.length) {
+      decimal = String(x);
+      return this;
+    }
+    return decimal;
+  };
+
+  /**
+   * Sets or gets the character used as the group separator, grouping integer
+   * digits by thousands. The default decimal point is ",". Grouping can be
+   * disabled by using "" for the separator.
+   *
+   * @param {string} [x] the new group separator.
+   * @returns {pv.Format.number} <tt>this</tt> or the current group separator.
+   */
+  format.group = function(x) {
+    if (arguments.length) {
+      group = x ? String(x) : "";
+      mins = mini + Math.floor(mini / 3) * group.length;
+      return this;
+    }
+    return group;
+  };
+
+  /**
+   * Sets or gets the negative prefix and suffix. The default negative prefix is
+   * "−", and the default negative suffix is the empty string.
+   *
+   * @param {string} [x] the negative prefix.
+   * @param {string} [y] the negative suffix.
+   * @returns {pv.Format.number} <tt>this</tt> or the current negative format.
+   */
+  format.negativeAffix = function(x, y) {
+    if (arguments.length) {
+      np = String(x || "");
+      ns = String(y || "");
+      return this;
+    }
+    return [np, ns];
+  };
+
+  return format;
+};
diff --git a/vendor/protovis/src/text/TimeFormat.js b/vendor/protovis/src/text/TimeFormat.js
new file mode 100644
index 0000000..045a05b
--- /dev/null
+++ b/vendor/protovis/src/text/TimeFormat.js
@@ -0,0 +1,115 @@
+/**
+ * Returns a time format of the given type, either "short" or "long".
+ *
+ * @class Represents a time format, converting between a <tt>number</tt>
+ * representing a duration in milliseconds, and a <tt>string</tt>. Two types of
+ * time formats are supported: "short" and "long". The <i>short</i> format type
+ * returns a string such as "3.3 days" or "12.1 minutes", while the <i>long</i>
+ * format returns "13:04:12" or similar.
+ *
+ * @extends pv.Format
+ * @param {string} type the type; "short" or "long".
+ */
+pv.Format.time = function(type) {
+  var pad = pv.Format.pad;
+
+  /*
+   * MILLISECONDS = 1
+   * SECONDS = 1e3
+   * MINUTES = 6e4
+   * HOURS = 36e5
+   * DAYS = 864e5
+   * WEEKS = 6048e5
+   * MONTHS = 2592e6
+   * YEARS = 31536e6
+   */
+
+  /** @private */
+  function format(t) {
+    t = Number(t); // force conversion from Date
+    switch (type) {
+      case "short": {
+        if (t >= 31536e6) {
+          return (t / 31536e6).toFixed(1) + " years";
+        } else if (t >= 6048e5) {
+          return (t / 6048e5).toFixed(1) + " weeks";
+        } else if (t >= 864e5) {
+          return (t / 864e5).toFixed(1) + " days";
+        } else if (t >= 36e5) {
+          return (t / 36e5).toFixed(1) + " hours";
+        } else if (t >= 6e4) {
+          return (t / 6e4).toFixed(1) + " minutes";
+        }
+        return (t / 1e3).toFixed(1) + " seconds";
+      }
+      case "long": {
+        var a = [],
+            s = ((t % 6e4) / 1e3) >> 0,
+            m = ((t % 36e5) / 6e4) >> 0;
+        a.push(pad("0", 2, s));
+        if (t >= 36e5) {
+          var h = ((t % 864e5) / 36e5) >> 0;
+          a.push(pad("0", 2, m));
+          if (t >= 864e5) {
+            a.push(pad("0", 2, h));
+            a.push(Math.floor(t / 864e5).toFixed());
+          } else {
+            a.push(h.toFixed());
+          }
+        } else {
+          a.push(m.toFixed());
+        }
+        return a.reverse().join(":");
+      }
+    }
+  }
+
+  /**
+   * Formats the specified time, returning the string representation.
+   *
+   * @function
+   * @name pv.Format.time.prototype.format
+   * @param {number} t the duration in milliseconds. May also be a <tt>Date</tt>.
+   * @returns {string} the formatted string.
+   */
+  format.format = format;
+
+  /**
+   * Parses the specified string, returning the time in milliseconds.
+   *
+   * @function
+   * @name pv.Format.time.prototype.parse
+   * @param {string} s a formatted string.
+   * @returns {number} the parsed duration in milliseconds.
+   */
+  format.parse = function(s) {
+    switch (type) {
+      case "short": {
+        var re = /([0-9,.]+)\s*([a-z]+)/g, a, t = 0;
+        while (a = re.exec(s)) {
+          var f = parseFloat(a[0].replace(",", "")), u = 0;
+          switch (a[2].toLowerCase()) {
+            case "year": case "years": u = 31536e6; break;
+            case "week": case "weeks": u = 6048e5; break;
+            case "day": case "days": u = 864e5; break;
+            case "hour": case "hours": u = 36e5; break;
+            case "minute": case "minutes": u = 6e4; break;
+            case "second": case "seconds": u = 1e3; break;
+          }
+          t += f * u;
+        }
+        return t;
+      }
+      case "long": {
+        var a = s.replace(",", "").split(":").reverse(), t = 0;
+        if (a.length) t += parseFloat(a[0]) * 1e3;
+        if (a.length > 1) t += parseFloat(a[1]) * 6e4;
+        if (a.length > 2) t += parseFloat(a[2]) * 36e5;
+        if (a.length > 3) t += parseFloat(a[3]) * 864e5;
+        return t;
+      }
+    }
+  }
+
+  return format;
+};
diff --git a/web/Rakefile b/web/Rakefile
new file mode 100644
index 0000000..819b2dc
--- /dev/null
+++ b/web/Rakefile
@@ -0,0 +1,53 @@
+# -*- ruby -*-
+require 'rake'
+require 'fileutils'
+directory "examples"
+
+rsvg_bin="rsvg-convert"
+
+def get_base(f)
+  f.sub(File.dirname(__FILE__)+"/../examples/","").gsub("/","_").gsub(".rb","")
+end
+EXAMPLES=Dir.glob(File.dirname(__FILE__)+"/../examples/**/*.rb").map {|v|     [v,get_base(v)]
+}.find_all{|v| !v[0].include?"_data"}
+
+EXAMPLES_BASE=EXAMPLES.map {|v| v[1]}
+
+
+desc "Build all html and svg files"
+task :build_site do
+  ruby "build_site.rb"
+end
+
+
+task :clean do
+  Dir.glob(File.dirname(__FILE__)+"/examples/*.svg").each do |t|
+    FileUtils.rm t
+  end
+  Dir.glob(File.dirname(__FILE__)+"/examples/*.html").each do |t|
+    FileUtils.rm t
+  end
+  Dir.glob(File.dirname(__FILE__)+"/examples/*.png").each do |t|
+    FileUtils.rm t
+  end
+  
+end
+task :default=>["examples", "index.html", "../lib/rubyvis.rb"]+EXAMPLES_BASE.map {|v| "examples/#{v}.html"}
+
+file "index.html"=>["index.haml", :build_site]+EXAMPLES_BASE.map {|v| "examples/#{v}.png"}
+
+EXAMPLES.each do |v|
+  e=v[1]
+  file "examples/#{e}.html"=>["examples.haml", "examples/#{e}.svg", :build_site, v[0]]
+  file "examples/#{e}.svg"=>[v[0]] do |t|
+    if !system "ruby #{v[0]} > #{t.name}"
+      FileUtils.rm t.name
+      exit
+    end
+  end
+  file "examples/#{e}.png"=>["examples/#{e}.svg"] do |t|
+    system   "#{rsvg_bin}  -w 200 -h 200 -f png -o #{t.name} examples/#{e}.svg "
+  end
+end
+
+load 'upload_task.rb' if File.exists? "upload_task.rb"
diff --git a/web/build_site.rb b/web/build_site.rb
new file mode 100644
index 0000000..f1ac4e2
--- /dev/null
+++ b/web/build_site.rb
@@ -0,0 +1,108 @@
+#!/usr/bin/ruby
+# * Create the index
+# * Create an html page for each example
+$:.unshift("../lib")
+require 'coderay'
+require 'haml'
+require 'ostruct'
+require 'rubyvis'
+require 'RedCloth'
+
+# First, create the examples
+
+haml_template=Haml::Engine.new(File.read("examples.haml"))
+buffer=[]
+
+def get_base(f)
+  f.sub(File.dirname(__FILE__)+"/../examples/","").gsub("/","_").gsub(".rb","")
+end
+
+# Store prev and next element
+pages={}
+prev_page=nil
+next_page=nil
+
+files=Dir.glob(File.dirname(__FILE__)+"/../examples/**/*.rb").sort{|a,b| puts "#{a}, #{b}"; a<=>b}
+files.each do |f|
+  
+  next if f.include? "_data.rb"
+  fn=get_base(f)
+  unless prev_page.nil?
+    pages[prev_page].next_ex = fn
+  end
+     
+  pages[fn]=OpenStruct.new({:prev_ex=>prev_page, :next_ex=>next_page, :name=>fn})
+  
+  prev_page=fn
+  
+  base=fn
+  
+  page=pages[fn]
+  mtime=File.mtime(f)
+  next if f.include? "_data.rb"
+  # First, get name and text
+  fp=File.open(f,"r")
+  comment=false
+  title=File.basename(f)
+  text=[]
+  source_a=[]
+  previous_example=""
+  next_example=""
+  title_obtained=false
+  fp.each do |line|
+    if line=~/\s*#\s*encoding:/
+      next
+    elsif line=~/\s*#\s*(.+)/ and !comment
+      t=$1
+      if t=~ /^=\s*(.+)$/ and !title_obtained
+        title=$1
+        title_obtained=true
+      else
+        text << t
+      end
+    else
+      comment=true
+      source_a << line unless line.include? "$:.unshift"
+    end
+  end
+  text.map! {|t| t.chomp}
+  # Create an html file with svg included inside
+  page.source=CodeRay.scan(source_a.join(), :ruby).div
+  page.title=title
+  page.text=RedCloth.new(text.join("\n")).to_html
+  page.svg_file=base+".svg"
+  # Read svg size
+  width=350
+  height=200
+  if File.exists? "examples/#{page.svg_file}"
+    File.open("examples/#{page.svg_file}","r") {|fp|
+      header=fp.gets(">")
+      if header=~/\sheight=['"]([^']+)['"]/ 
+        height=$1
+      end
+      if header=~/\swidth=['"]([^']+)['"]/
+        width=$1
+      end
+    }
+  end
+  page.svg_width=width.to_f.ceil
+  page.svg_height=height.to_f.ceil
+
+end
+
+pages.each do |name, page|
+  html_file="examples/#{page.name}.html"
+  File.open(html_file,"w") {|fp|
+    fp.write(haml_template.render(page, :pages=>pages))
+  }
+  
+end
+
+
+
+# Create index
+
+index_template=Haml::Engine.new(File.read("index.haml"))
+File.open("index.html","w") {|fp|
+  fp.write(index_template.render(self,:examples=>pages))
+}
diff --git a/web/examples.haml b/web/examples.haml
new file mode 100644
index 0000000..40bc1d8
--- /dev/null
+++ b/web/examples.haml
@@ -0,0 +1,35 @@
+!!!
+%html
+  %head
+    %link{:type=>"text/css", :rel=>"stylesheet", :href=>"../style.css"}
+    %title="Rubyvis - Example: #{title}"
+  %body
+    %h1="Rubyvis - Example: #{title}"
+    .example_main
+      .description=find_and_preserve(text)
+      .navigation
+        %ul
+          %li 
+            %a{:href=>"../index.html"} Home
+          - if prev_ex
+            %li
+              %a{:href=>"#{prev_ex}.html"} Previous: #{pages[prev_ex].title}
+          - if next_ex
+            %li
+              %a{:href=>"#{next_ex}.html"} Next: #{pages[next_ex].title}          
+      .image
+        /[if IE]
+          %embed.svg{:src=>svg_file,:width=>svg_width, :height=>svg_height}
+        %object.svg{:data=>svg_file, :type=>"image/svg+xml", :width=>svg_width, :height=>svg_height}
+      .source=find_and_preserve(source)
+    :javascript
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', 'UA-5764936-8']);
+      _gaq.push(['_trackPageview']);
+      
+      (function() {
+      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+      })();
+
diff --git a/web/index.haml b/web/index.haml
new file mode 100644
index 0000000..73ebdca
--- /dev/null
+++ b/web/index.haml
@@ -0,0 +1,121 @@
+!!!
+%html
+  %head
+    %link{:type=>"text/css", :rel=>"stylesheet", :href=>"style.css"}
+    %title Rubyvis: Ruby version of Protovis
+  %body
+    %h1 Rubyvis
+    %h2 Description
+    .description
+      %p 
+        Ruby port of 
+        %a{:href=>"http://vis.stanford.edu/protovis/"} Protovis library
+        According to the protovis site
+        %blockquote
+          Protovis composes custom views of data with simple marks such as bars and dots. Unlike low-level graphics libraries that quickly become tedious for visualization, Protovis defines marks through dynamic properties that encode data, allowing inheritance, scales and layouts to simplify construction.
+        %p As Protovis, Rubyvis is free and open-source, provided under the BSD License. Its delivers SVG natively, which could be exported to PNG, JPEG and others graphics formats 
+        %p 
+          Current Version:
+          %strong=Rubyvis::VERSION
+        %p 
+          Protovis API Version:
+          %strong=Rubyvis::PROTOVIS_API_VERSION
+    %h2 Installation
+    %pre gem install rubyvis
+    %h2 Synopsis
+    .synopsis
+      #ruby_code
+        %h3 Ruby
+        %pre 
+          :preserve
+            require 'rubygems'
+            require 'rubyvis'
+            vis = Rubyvis::Panel.new do 
+              width 150
+              height 150
+              bar do
+                data [1, 1.2, 1.7, 1.5, 0.7, 0.3]
+                width 20
+                height {|d| d * 80}
+                bottom(0)
+                left {index * 25}
+              end
+            end
+            vis.render()
+            puts vis.to_svg # Output final SVG
+      #svg_code
+        %h3 SVG
+        %pre
+          :preserve
+            <svg fill="none" font-family="sans-serif" 
+            font-size="10px" height="150.0" stroke="none" 
+            stroke-width="1.5" width="150.0">
+            <g transform="translate(0.0,0.0)">
+            <rect fill="rgb(31,119,180)" height="80" 
+            width="20" y="70"/>
+            <rect fill="rgb(31,119,180)" height="96.0" 
+            width="20" x="25" y="54.0"/>
+            <rect fill="rgb(31,119,180)" height="136.0" 
+            width="20" x="50" y="14.0"/>
+            <rect fill="rgb(31,119,180)" height="120.0" 
+            width="20" x="75" y="30.0"/>
+            <rect fill="rgb(31,119,180)" height="56.0" 
+            width="20"  x="100" y="94.0"/>
+            <rect fill="rgb(31,119,180)" height="24.0" 
+            width="20" x="125" y="126.0"/>
+            </g>
+            </svg>
+      #image
+        %div
+          %h3 Image
+          /[if IE]
+            %embed{:src=>"examples/1_basic_1a_bar_rbp_api.svg" ,:width=>"150", :height=>"150"}
+          %object{:data=>"examples/1_basic_1a_bar_rbp_api.svg", :type=>"image/svg+xml", :width=>150,:height=>150}
+    .resources
+      %h2 Resources
+      %ul
+        %li
+          source code on
+          %a{:href=>'http://github.com/clbustos/rubyvis'}
+            Github
+        %li
+          requests and bug reports on 
+          %a{:href=>'http://github.com/clbustos/rubyvis/issues'}
+            Github, too
+        %li
+          gem on 
+          %a{:href=>'http://rubygems.org/gems/rubyvis'}
+            gemcutter
+        %li
+          API documentation on 
+          %a{:href=>'http://rubyvis.rubyforge.org/rubyvis/'}
+            http://rubyvis.rubyforge.org/rubyvis/
+    .adsense_1
+      :javascript
+        google_ad_client = "ca-pub-8946586062292381";
+        /* rubyvis_1 */
+        google_ad_slot = "8253377596";
+        google_ad_width = 728;
+        google_ad_height = 90;
+      %script{:type=>'text/javascript', :src=>"http://pagead2.googlesyndication.com/pagead/show_ads.js"}
+    .examples_div
+      %h2 Examples
+      %p 
+        Several based on
+        %a{:href=>"http://vis.stanford.edu/protovis/ex/"}Protovis gallery
+      .examples
+        - examples.each_pair do |name,page|
+          .example
+            .name
+              %a{:href=>"examples/"+name+".html"}=page.title
+            .image
+              %img{:src=>"examples/"+name+".png"}
+    :javascript
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', 'UA-5764936-8']);
+      _gaq.push(['_trackPageview']);
+      (function() {
+      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+      })();
diff --git a/web/style.css b/web/style.css
new file mode 100644
index 0000000..8b7d52e
--- /dev/null
+++ b/web/style.css
@@ -0,0 +1,82 @@
+body {
+  background-color: white;
+  color: black;
+  padding: 0;
+  font-family: "Arial",sans-serif;
+}
+
+h1,h2,h3 {
+	color:#600;
+}
+
+.example .name {
+text-align:center;
+margin-bottom:0.5em;
+}
+
+.example .image {
+}
+
+.example {
+float:left;
+border:1px solid #ccc;
+padding:1em;
+margin:1em;
+}
+
+.description {
+    border:1px solid #dcc;
+    background: #ffefef;
+    padding:0.5em;
+    margin-bottom:1em;
+}
+
+.examples_div, .resources {
+    clear:both;
+}
+#image {
+    float:left;
+    width:auto; 
+    font-size:8pt;
+    margin:1em;
+    padding:0.5em 1em;
+    border:1px solid #ccc;
+    height:auto;
+
+}
+#ruby_code, #svg_code {
+    float:left;
+    width:30%;
+    font-size:8pt;
+    margin:1em;
+    padding:0.5em;
+    border:1px solid #ccc;
+    height:auto;
+}
+
+.synopsis h3 {
+    font-size:12pt;
+    text-align:center;
+}
+
+.example_main .description {
+clear:both;
+}
+.example_main .image {
+    float:left;
+}
+
+.navigation {
+    font-size:80%;
+    margin: 0.2em 0em 2em 2em;
+}
+.navigation ul {
+    list-style:none;
+}
+.example_main .source {
+    float:right;
+    width:40%;
+    margin: 0.5em 1em;
+    border:1px solid #ccc;
+    padding:1em;
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-rubyvis.git



More information about the Pkg-ruby-extras-commits mailing list