rubyvis 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -1
- data/Manifest.txt +421 -1
- data/README.txt +12 -10
- data/examples/first.rb +2 -2
- data/examples/second.rb +6 -3
- data/lib/rubyvis.rb +18 -3
- data/lib/rubyvis/mark.rb +101 -83
- data/lib/rubyvis/mark/anchor.rb +5 -7
- data/lib/rubyvis/mark/area.rb +19 -17
- data/lib/rubyvis/mark/bar.rb +3 -10
- data/lib/rubyvis/mark/label.rb +3 -4
- data/lib/rubyvis/mark/line.rb +20 -4
- data/lib/rubyvis/mark/panel.rb +31 -6
- data/lib/rubyvis/mark/rule.rb +8 -4
- data/lib/rubyvis/property.rb +11 -0
- data/lib/rubyvis/scene/svg_label.rb +1 -1
- data/lib/rubyvis/scene/svg_scene.rb +2 -1
- data/lib/rubyvis/sceneelement.rb +2 -0
- data/spec/bar_spec.rb +50 -0
- data/spec/label_spec.rb +41 -0
- data/spec/mark_spec.rb +16 -0
- data/spec/panel_spec.rb +22 -4
- data/spec/spec_helper.rb +1 -0
- data/vendor/FUTURE +62 -0
- data/vendor/Makefile +138 -0
- data/vendor/TODO +22 -0
- data/vendor/examples/antibiotics/antibiotics-scatter.html +113 -0
- data/vendor/examples/antibiotics/antibiotics.html +140 -0
- data/vendor/examples/antibiotics/antibiotics.js +20 -0
- data/vendor/examples/barley/barley.html +102 -0
- data/vendor/examples/barley/barley.js +122 -0
- data/vendor/examples/cars/cars.html +90 -0
- data/vendor/examples/cars/cars.js +408 -0
- data/vendor/examples/clock/clock.html +91 -0
- data/vendor/examples/crimea/crimea-grouped-bar.html +65 -0
- data/vendor/examples/crimea/crimea-line.html +61 -0
- data/vendor/examples/crimea/crimea-stacked-area.html +61 -0
- data/vendor/examples/crimea/crimea-stacked-bar.html +60 -0
- data/vendor/examples/crimea/crimea.html +100 -0
- data/vendor/examples/crimea/crimea.js +33 -0
- data/vendor/examples/downloadify/LICENSE.txt +22 -0
- data/vendor/examples/downloadify/download.png +0 -0
- data/vendor/examples/downloadify/downloadify.html +57 -0
- data/vendor/examples/downloadify/downloadify.min.js +3 -0
- data/vendor/examples/downloadify/downloadify.swf +0 -0
- data/vendor/examples/downloadify/swfobject.js +4 -0
- data/vendor/examples/ex.css +17 -0
- data/vendor/examples/eyes/eyes.html +53 -0
- data/vendor/examples/eyes/matrix.html +44 -0
- data/vendor/examples/flowers/flowers.html +109 -0
- data/vendor/examples/flowers/flowers.js +154 -0
- data/vendor/examples/group-stack/group-stack.html +79 -0
- data/vendor/examples/group-stack/headcount.js +23 -0
- data/vendor/examples/hotel/hotel.html +76 -0
- data/vendor/examples/hotel/hotel.js +245 -0
- data/vendor/examples/jobs/jobs.html +71 -0
- data/vendor/examples/jobs/jobs.js +1024 -0
- data/vendor/examples/jquery-1.4.2.min.js +154 -0
- data/vendor/examples/nba/nba.html +83 -0
- data/vendor/examples/nba/nba.js +53 -0
- data/vendor/examples/nba/nba2.html +82 -0
- data/vendor/examples/sankey/gdp2009.js +184 -0
- data/vendor/examples/sankey/sankey.html +77 -0
- data/vendor/examples/slider/cell.html +112 -0
- data/vendor/examples/slider/cell.js +31 -0
- data/vendor/examples/slider/horizon.html +85 -0
- data/vendor/examples/slider/jquery-ui-1.8rc3.custom.min.js +71 -0
- data/vendor/examples/slider/slider.html +50 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-icons_222222_256x240.png +2 -0
- data/vendor/examples/slider/ui-lightness/images/ui-icons_228ef1_256x240.png +2 -0
- data/vendor/examples/slider/ui-lightness/images/ui-icons_ef8c08_256x240.png +2 -0
- data/vendor/examples/slider/ui-lightness/images/ui-icons_ffd27a_256x240.png +2 -0
- data/vendor/examples/slider/ui-lightness/images/ui-icons_ffffff_256x240.png +2 -0
- data/vendor/examples/slider/ui-lightness/jquery-ui-1.8rc3.custom.css +302 -0
- data/vendor/examples/tipsy/jquery.tipsy.js +198 -0
- data/vendor/examples/tipsy/tipsy-bar.html +65 -0
- data/vendor/examples/tipsy/tipsy-line.html +67 -0
- data/vendor/examples/tipsy/tipsy.css +12 -0
- data/vendor/examples/tipsy/tipsy.gif +0 -0
- data/vendor/examples/tipsy/tipsy.js +66 -0
- data/vendor/examples/weather/weather.html +86 -0
- data/vendor/examples/weather/weather.js +42 -0
- data/vendor/examples/wheat/wheat.html +130 -0
- data/vendor/examples/wheat/wheat.js +70 -0
- data/vendor/lib/google-compiler/COPYING +202 -0
- data/vendor/lib/google-compiler/README +224 -0
- data/vendor/lib/google-compiler/compiler-20100201.jar +0 -0
- data/vendor/protovis-d3.3.js +15726 -0
- data/vendor/protovis-r3.3.js +287 -0
- data/vendor/src/behavior/Behavior.js +32 -0
- data/vendor/src/behavior/Drag.js +112 -0
- data/vendor/src/behavior/Pan.js +110 -0
- data/vendor/src/behavior/Point.js +157 -0
- data/vendor/src/behavior/Resize.js +104 -0
- data/vendor/src/behavior/Select.js +100 -0
- data/vendor/src/behavior/Zoom.js +85 -0
- data/vendor/src/color/Color.js +598 -0
- data/vendor/src/color/Colors.js +135 -0
- data/vendor/src/color/Ramp.js +17 -0
- data/vendor/src/data/Arrays.js +277 -0
- data/vendor/src/data/Dom.js +380 -0
- data/vendor/src/data/Flatten.js +146 -0
- data/vendor/src/data/Histogram.js +120 -0
- data/vendor/src/data/LinearScale.js +54 -0
- data/vendor/src/data/LogScale.js +142 -0
- data/vendor/src/data/Nest.js +257 -0
- data/vendor/src/data/Numbers.js +313 -0
- data/vendor/src/data/Objects.js +78 -0
- data/vendor/src/data/OrdinalScale.js +267 -0
- data/vendor/src/data/QuantileScale.js +180 -0
- data/vendor/src/data/QuantitativeScale.js +440 -0
- data/vendor/src/data/RootScale.js +55 -0
- data/vendor/src/data/Scale.js +86 -0
- data/vendor/src/data/Transform.js +109 -0
- data/vendor/src/data/Tree.js +124 -0
- data/vendor/src/data/Vector.js +118 -0
- data/vendor/src/geo/Geo.js +5 -0
- data/vendor/src/geo/GeoScale.js +307 -0
- data/vendor/src/geo/LatLng.js +23 -0
- data/vendor/src/geo/Projection.js +43 -0
- data/vendor/src/geo/Projections.js +117 -0
- data/vendor/src/lang/Array.js +112 -0
- data/vendor/src/lang/init.js +26 -0
- data/vendor/src/layout/Arc.js +178 -0
- data/vendor/src/layout/Bullet.js +164 -0
- data/vendor/src/layout/Cluster.js +205 -0
- data/vendor/src/layout/Force.js +309 -0
- data/vendor/src/layout/Grid.js +119 -0
- data/vendor/src/layout/Hierarchy.js +249 -0
- data/vendor/src/layout/Horizon.js +159 -0
- data/vendor/src/layout/Indent.js +83 -0
- data/vendor/src/layout/Layout.js +56 -0
- data/vendor/src/layout/Matrix.js +177 -0
- data/vendor/src/layout/Network.js +302 -0
- data/vendor/src/layout/Pack.js +323 -0
- data/vendor/src/layout/Partition.js +203 -0
- data/vendor/src/layout/Rollup.js +203 -0
- data/vendor/src/layout/Stack.js +391 -0
- data/vendor/src/layout/Tree.js +282 -0
- data/vendor/src/layout/Treemap.js +347 -0
- data/vendor/src/mark/Anchor.js +81 -0
- data/vendor/src/mark/Area.js +268 -0
- data/vendor/src/mark/Bar.js +93 -0
- data/vendor/src/mark/Dot.js +212 -0
- data/vendor/src/mark/Ease.js +150 -0
- data/vendor/src/mark/Image.js +154 -0
- data/vendor/src/mark/Label.js +155 -0
- data/vendor/src/mark/Line.js +195 -0
- data/vendor/src/mark/Mark.js +1237 -0
- data/vendor/src/mark/Panel.js +273 -0
- data/vendor/src/mark/Rule.js +143 -0
- data/vendor/src/mark/Transient.js +7 -0
- data/vendor/src/mark/Transition.js +195 -0
- data/vendor/src/mark/Wedge.js +244 -0
- data/vendor/src/physics/BoundConstraint.js +75 -0
- data/vendor/src/physics/ChargeForce.js +184 -0
- data/vendor/src/physics/CollisionConstraint.js +113 -0
- data/vendor/src/physics/Constraint.js +26 -0
- data/vendor/src/physics/DragForce.js +49 -0
- data/vendor/src/physics/Force.js +25 -0
- data/vendor/src/physics/Particle.js +81 -0
- data/vendor/src/physics/PositionConstraint.js +72 -0
- data/vendor/src/physics/Quadtree.js +195 -0
- data/vendor/src/physics/Simulation.js +159 -0
- data/vendor/src/physics/SpringForce.js +141 -0
- data/vendor/src/pv-internals.js +154 -0
- data/vendor/src/pv.js +95 -0
- data/vendor/src/scene/SvgArea.js +172 -0
- data/vendor/src/scene/SvgBar.js +28 -0
- data/vendor/src/scene/SvgCurve.js +354 -0
- data/vendor/src/scene/SvgDot.js +81 -0
- data/vendor/src/scene/SvgImage.js +45 -0
- data/vendor/src/scene/SvgLabel.js +46 -0
- data/vendor/src/scene/SvgLine.js +159 -0
- data/vendor/src/scene/SvgPanel.js +126 -0
- data/vendor/src/scene/SvgRule.js +26 -0
- data/vendor/src/scene/SvgScene.js +185 -0
- data/vendor/src/scene/SvgWedge.js +66 -0
- data/vendor/src/text/DateFormat.js +262 -0
- data/vendor/src/text/Format.js +78 -0
- data/vendor/src/text/NumberFormat.js +227 -0
- data/vendor/src/text/TimeFormat.js +115 -0
- data/vendor/test1.html +30 -0
- data/vendor/tests/behavior/drag-events.html +47 -0
- data/vendor/tests/behavior/drag.html +32 -0
- data/vendor/tests/behavior/drag2.html +33 -0
- data/vendor/tests/behavior/point-area-stacked.html +73 -0
- data/vendor/tests/behavior/point-area-stacked2.html +70 -0
- data/vendor/tests/behavior/point-area.html +67 -0
- data/vendor/tests/behavior/point-bar.html +62 -0
- data/vendor/tests/behavior/point-dot.html +60 -0
- data/vendor/tests/behavior/point-line.html +62 -0
- data/vendor/tests/behavior/point-lines-grid.html +65 -0
- data/vendor/tests/behavior/point-lines.html +61 -0
- data/vendor/tests/behavior/point-wedge.html +43 -0
- data/vendor/tests/behavior/resize.html +69 -0
- data/vendor/tests/behavior/select.html +37 -0
- data/vendor/tests/bzr.js +62 -0
- data/vendor/tests/center.js +13 -0
- data/vendor/tests/data/deviation.html +54 -0
- data/vendor/tests/data/histogram-discrete.html +50 -0
- data/vendor/tests/data/histogram.html +56 -0
- data/vendor/tests/data/log-adjusted.html +48 -0
- data/vendor/tests/data/log-ceil.html +48 -0
- data/vendor/tests/data/log-floor.html +48 -0
- data/vendor/tests/data/log-symmetric.html +48 -0
- data/vendor/tests/data/log.html +48 -0
- data/vendor/tests/data/max-index.html +36 -0
- data/vendor/tests/data/max.html +36 -0
- data/vendor/tests/data/min-index.html +36 -0
- data/vendor/tests/data/min.html +36 -0
- data/vendor/tests/data/ordinal-split-banded.html +45 -0
- data/vendor/tests/data/ordinal-split-banded2.html +45 -0
- data/vendor/tests/data/ordinal-split-flush.html +51 -0
- data/vendor/tests/data/ordinal-split.html +51 -0
- data/vendor/tests/data/range.html +105 -0
- data/vendor/tests/data/scale-date.html +46 -0
- data/vendor/tests/data/scale-date2.html +38 -0
- data/vendor/tests/data/scale-date3.html +38 -0
- data/vendor/tests/data/scale-date4.html +38 -0
- data/vendor/tests/data/scale-degenerate.html +143 -0
- data/vendor/tests/data/scale-linear.html +59 -0
- data/vendor/tests/data/scale-log.html +60 -0
- data/vendor/tests/data/scale-log2.html +60 -0
- data/vendor/tests/data/scale-log3.html +60 -0
- data/vendor/tests/data/scale-log4.html +60 -0
- data/vendor/tests/data/scale-log5.html +60 -0
- data/vendor/tests/data/scale-log6.html +60 -0
- data/vendor/tests/data/scale-quantile.html +47 -0
- data/vendor/tests/data/scale-quantile2.html +50 -0
- data/vendor/tests/data/scale-quantile3.html +48 -0
- data/vendor/tests/data/scale-root.html +60 -0
- data/vendor/tests/data/scale-root2.html +39 -0
- data/vendor/tests/data/scale-tick-format.html +54 -0
- data/vendor/tests/data/scale-ticks.html +45 -0
- data/vendor/tests/data/sum.html +42 -0
- data/vendor/tests/data/variance.html +42 -0
- data/vendor/tests/diamond.js +40 -0
- data/vendor/tests/flare-imports.js +222 -0
- data/vendor/tests/flare.js +284 -0
- data/vendor/tests/geo/countries-hires.js +257 -0
- data/vendor/tests/geo/countries-lores.js +197 -0
- data/vendor/tests/geo/population.js +250 -0
- data/vendor/tests/geo/scale-aitoff.html +58 -0
- data/vendor/tests/geo/scale-gall-peters.html +56 -0
- data/vendor/tests/geo/scale-hammer.html +58 -0
- data/vendor/tests/geo/scale-identity.html +56 -0
- data/vendor/tests/geo/scale-mercator.html +56 -0
- data/vendor/tests/geo/scale-sinusoidal.html +57 -0
- data/vendor/tests/geo/scale-smart-domain.html +58 -0
- data/vendor/tests/geo/scale.html +55 -0
- data/vendor/tests/geo/scale2.html +40 -0
- data/vendor/tests/geo/us-states.js +61 -0
- data/vendor/tests/heatmap.js +63 -0
- data/vendor/tests/lang/globals.html +41 -0
- data/vendor/tests/lang/init.html +31 -0
- data/vendor/tests/layers.js +28 -0
- data/vendor/tests/layout/arc-directed.html +33 -0
- data/vendor/tests/layout/arc-radial.html +36 -0
- data/vendor/tests/layout/arc-undirected.html +32 -0
- data/vendor/tests/layout/arc.html +33 -0
- data/vendor/tests/layout/arc2.html +32 -0
- data/vendor/tests/layout/bullet-multiples.html +60 -0
- data/vendor/tests/layout/bullet.html +45 -0
- data/vendor/tests/layout/bullets.js +37 -0
- data/vendor/tests/layout/cluster-fill-group.html +24 -0
- data/vendor/tests/layout/cluster-fill.html +28 -0
- data/vendor/tests/layout/cluster-partition-radial-fill.html +43 -0
- data/vendor/tests/layout/cluster-radial-fill-radius.html +26 -0
- data/vendor/tests/layout/cluster-radial-fill.html +29 -0
- data/vendor/tests/layout/cluster-radial-group-fill.html +30 -0
- data/vendor/tests/layout/cluster-radial-radius.html +30 -0
- data/vendor/tests/layout/cluster-radial.html +28 -0
- data/vendor/tests/layout/cluster-radial2.html +33 -0
- data/vendor/tests/layout/cluster.html +34 -0
- data/vendor/tests/layout/cluster2.html +32 -0
- data/vendor/tests/layout/force-toggle.html +46 -0
- data/vendor/tests/layout/force.html +45 -0
- data/vendor/tests/layout/force2.html +58 -0
- data/vendor/tests/layout/force3.html +41 -0
- data/vendor/tests/layout/force4.html +45 -0
- data/vendor/tests/layout/force5.html +53 -0
- data/vendor/tests/layout/grid-cols.html +31 -0
- data/vendor/tests/layout/grid-heatmap.html +25 -0
- data/vendor/tests/layout/grid-rows.html +31 -0
- data/vendor/tests/layout/grid.html +34 -0
- data/vendor/tests/layout/horizon-color.html +31 -0
- data/vendor/tests/layout/horizon.html +31 -0
- data/vendor/tests/layout/indent-toggle.html +62 -0
- data/vendor/tests/layout/indent.html +25 -0
- data/vendor/tests/layout/indent2.html +33 -0
- data/vendor/tests/layout/matrix-sort.html +28 -0
- data/vendor/tests/layout/matrix.html +35 -0
- data/vendor/tests/layout/network.html +43 -0
- data/vendor/tests/layout/pack-bubble.html +45 -0
- data/vendor/tests/layout/pack.html +26 -0
- data/vendor/tests/layout/pack2.html +32 -0
- data/vendor/tests/layout/partition-fill.html +27 -0
- data/vendor/tests/layout/partition-fill2.html +22 -0
- data/vendor/tests/layout/partition-fill3.html +27 -0
- data/vendor/tests/layout/partition-radial-fill-radius.html +25 -0
- data/vendor/tests/layout/partition-radial-fill.html +26 -0
- data/vendor/tests/layout/partition-radial-fill2.html +23 -0
- data/vendor/tests/layout/partition-radial-fill3.html +29 -0
- data/vendor/tests/layout/partition-radial-radius.html +29 -0
- data/vendor/tests/layout/partition-radial.html +30 -0
- data/vendor/tests/layout/partition-radial2.html +33 -0
- data/vendor/tests/layout/partition.html +33 -0
- data/vendor/tests/layout/partition2.html +32 -0
- data/vendor/tests/layout/rollup.html +50 -0
- data/vendor/tests/layout/stack-empty.html +27 -0
- data/vendor/tests/layout/stack-expand.html +41 -0
- data/vendor/tests/layout/stack-reverse.html +42 -0
- data/vendor/tests/layout/stack-right.html +42 -0
- data/vendor/tests/layout/stack-rule.html +61 -0
- data/vendor/tests/layout/stack-visible.html +43 -0
- data/vendor/tests/layout/stack.html +53 -0
- data/vendor/tests/layout/tree-radial.html +31 -0
- data/vendor/tests/layout/tree-radial2.html +34 -0
- data/vendor/tests/layout/tree-toggle.html +36 -0
- data/vendor/tests/layout/tree.html +31 -0
- data/vendor/tests/layout/tree2.html +35 -0
- data/vendor/tests/layout/treemap-hierarchy.html +40 -0
- data/vendor/tests/layout/treemap-margin.html +26 -0
- data/vendor/tests/layout/treemap-round.html +40 -0
- data/vendor/tests/layout/treemap-slice.html +34 -0
- data/vendor/tests/layout/treemap.html +37 -0
- data/vendor/tests/life.js +212 -0
- data/vendor/tests/mark/anchor.html +25 -0
- data/vendor/tests/mark/area-anchor-chain.html +42 -0
- data/vendor/tests/mark/area-anchor-line.html +57 -0
- data/vendor/tests/mark/area-anchor-stack.html +35 -0
- data/vendor/tests/mark/area-anchor.html +43 -0
- data/vendor/tests/mark/area-anchor2.html +33 -0
- data/vendor/tests/mark/area-cardinal.html +57 -0
- data/vendor/tests/mark/area-monotone.html +57 -0
- data/vendor/tests/mark/area-segmented-basis.html +30 -0
- data/vendor/tests/mark/area-segmented-cardinal.html +30 -0
- data/vendor/tests/mark/area-segmented-monotone.html +30 -0
- data/vendor/tests/mark/area-segmented-step.html +44 -0
- data/vendor/tests/mark/area-segmented.html +29 -0
- data/vendor/tests/mark/area-stacked-cardinal.html +54 -0
- data/vendor/tests/mark/area-stacked-monotone.html +54 -0
- data/vendor/tests/mark/area-stacked.html +53 -0
- data/vendor/tests/mark/area-step.html +43 -0
- data/vendor/tests/mark/area-zero.html +32 -0
- data/vendor/tests/mark/area.html +57 -0
- data/vendor/tests/mark/bar-anchor-stack.html +51 -0
- data/vendor/tests/mark/bar-anchor.html +44 -0
- data/vendor/tests/mark/bar-column-grouped.html +63 -0
- data/vendor/tests/mark/bar-column-stacked.html +56 -0
- data/vendor/tests/mark/bar-column.html +54 -0
- data/vendor/tests/mark/bar-grouped.html +63 -0
- data/vendor/tests/mark/bar-stacked.html +57 -0
- data/vendor/tests/mark/bar.html +54 -0
- data/vendor/tests/mark/cursor.html +41 -0
- data/vendor/tests/mark/def-type.html +23 -0
- data/vendor/tests/mark/dot-anchor.html +33 -0
- data/vendor/tests/mark/dot-radius.html +22 -0
- data/vendor/tests/mark/dot-stroke.html +43 -0
- data/vendor/tests/mark/dot.html +52 -0
- data/vendor/tests/mark/dot2.html +61 -0
- data/vendor/tests/mark/ease.html +90 -0
- data/vendor/tests/mark/event-dblclick.html +30 -0
- data/vendor/tests/mark/event-prototype.html +45 -0
- data/vendor/tests/mark/event-render.html +45 -0
- data/vendor/tests/mark/event.html +24 -0
- data/vendor/tests/mark/image-color-inherit.html +33 -0
- data/vendor/tests/mark/image-color.html +35 -0
- data/vendor/tests/mark/image-color2.html +35 -0
- data/vendor/tests/mark/image-heatmap.html +29 -0
- data/vendor/tests/mark/image.html +32 -0
- data/vendor/tests/mark/label-break.html +54 -0
- data/vendor/tests/mark/label-decoration.html +22 -0
- data/vendor/tests/mark/label-events.html +32 -0
- data/vendor/tests/mark/line-anchor.html +42 -0
- data/vendor/tests/mark/line-basis.html +54 -0
- data/vendor/tests/mark/line-brownian.html +57 -0
- data/vendor/tests/mark/line-cardinal.html +77 -0
- data/vendor/tests/mark/line-catmull-rom.html +78 -0
- data/vendor/tests/mark/line-curve.html +65 -0
- data/vendor/tests/mark/line-eccentricity.html +39 -0
- data/vendor/tests/mark/line-fill.html +24 -0
- data/vendor/tests/mark/line-join.html +51 -0
- data/vendor/tests/mark/line-monotone-non-monotone.html +53 -0
- data/vendor/tests/mark/line-monotone-two-way.html +61 -0
- data/vendor/tests/mark/line-monotone.html +53 -0
- data/vendor/tests/mark/line-polar.html +36 -0
- data/vendor/tests/mark/line-segmented-basis.html +57 -0
- data/vendor/tests/mark/line-segmented-cardinal.html +80 -0
- data/vendor/tests/mark/line-segmented-join.html +52 -0
- data/vendor/tests/mark/line-segmented-monotone.html +56 -0
- data/vendor/tests/mark/line-segmented-polar.html +30 -0
- data/vendor/tests/mark/line-segmented-step.html +41 -0
- data/vendor/tests/mark/line-segmented-step2.html +32 -0
- data/vendor/tests/mark/line-segmented.html +30 -0
- data/vendor/tests/mark/line-step.html +39 -0
- data/vendor/tests/mark/line-tension.html +59 -0
- data/vendor/tests/mark/line.html +51 -0
- data/vendor/tests/mark/panel-anchor.html +37 -0
- data/vendor/tests/mark/panel-anchor2.html +31 -0
- data/vendor/tests/mark/panel-anchor3.html +22 -0
- data/vendor/tests/mark/panel-anchor4.html +28 -0
- data/vendor/tests/mark/panel-anchor5.html +28 -0
- data/vendor/tests/mark/panel-append.html +29 -0
- data/vendor/tests/mark/panel-canvas.html +107 -0
- data/vendor/tests/mark/panel-fill.html +50 -0
- data/vendor/tests/mark/panel-mouse.html +53 -0
- data/vendor/tests/mark/panel-transform.html +67 -0
- data/vendor/tests/mark/property-cast.html +24 -0
- data/vendor/tests/mark/render-partial.html +42 -0
- data/vendor/tests/mark/rule-anchor.html +29 -0
- data/vendor/tests/mark/title.html +41 -0
- data/vendor/tests/mark/transition-anchor.html +47 -0
- data/vendor/tests/mark/transition-wedge.html +47 -0
- data/vendor/tests/mark/transition.html +106 -0
- data/vendor/tests/mark/wedge-donut.html +35 -0
- data/vendor/tests/mark/wedge-implied.html +42 -0
- data/vendor/tests/mark/wedge-pie.html +37 -0
- data/vendor/tests/mark/wedge-ring.html +27 -0
- data/vendor/tests/miserables.js +348 -0
- data/vendor/tests/physics/dorling.html +70 -0
- data/vendor/tests/physics/simulation.html +56 -0
- data/vendor/tests/social.js +28 -0
- data/vendor/tests/stanford.png +0 -0
- data/vendor/tests/style.css +5 -0
- data/vendor/tests/testify.css +29 -0
- data/vendor/tests/testify.js +16 -0
- data/vendor/tests/text/format-number.html +75 -0
- data/web/first.svg +1 -0
- data/web/index.html +48 -0
- metadata +434 -31
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -2
@@ -0,0 +1,282 @@
|
|
1
|
+
/**
|
2
|
+
* Constructs a new, empty tree layout. Layouts are not typically constructed
|
3
|
+
* directly; instead, they are added to an existing panel via
|
4
|
+
* {@link pv.Mark#add}.
|
5
|
+
*
|
6
|
+
* @class Implements a node-link tree diagram using the Reingold-Tilford "tidy"
|
7
|
+
* tree layout algorithm. The specific algorithm used by this layout is based on
|
8
|
+
* <a href="http://citeseer.ist.psu.edu/buchheim02improving.html">"Improving
|
9
|
+
* Walker's Algorithm to Run in Linear Time"</A> by C. Buchheim, M. Jünger
|
10
|
+
* & S. Leipert, Graph Drawing 2002. This layout supports both cartesian and
|
11
|
+
* radial orientations orientations for node-link diagrams.
|
12
|
+
*
|
13
|
+
* <p>The tree layout supports a "group" property, which if true causes siblings
|
14
|
+
* to be positioned closer together than unrelated nodes at the same depth. The
|
15
|
+
* layout can be configured using the <tt>depth</tt> and <tt>breadth</tt>
|
16
|
+
* properties, which control the increments in pixel space between nodes in both
|
17
|
+
* dimensions, similar to the indent layout.
|
18
|
+
*
|
19
|
+
* <p>For more details on how to use this layout, see
|
20
|
+
* {@link pv.Layout.Hierarchy}.
|
21
|
+
*
|
22
|
+
* @extends pv.Layout.Hierarchy
|
23
|
+
*/
|
24
|
+
pv.Layout.Tree = function() {
|
25
|
+
pv.Layout.Hierarchy.call(this);
|
26
|
+
};
|
27
|
+
|
28
|
+
pv.Layout.Tree.prototype = pv.extend(pv.Layout.Hierarchy)
|
29
|
+
.property("group", Number)
|
30
|
+
.property("breadth", Number)
|
31
|
+
.property("depth", Number)
|
32
|
+
.property("orient", String);
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Default properties for tree layouts. The default orientation is "top", the
|
36
|
+
* default group parameter is 1, and the default breadth and depth offsets are
|
37
|
+
* 15 and 60 respectively.
|
38
|
+
*
|
39
|
+
* @type pv.Layout.Tree
|
40
|
+
*/
|
41
|
+
pv.Layout.Tree.prototype.defaults = new pv.Layout.Tree()
|
42
|
+
.extend(pv.Layout.Hierarchy.prototype.defaults)
|
43
|
+
.group(1)
|
44
|
+
.breadth(15)
|
45
|
+
.depth(60)
|
46
|
+
.orient("top");
|
47
|
+
|
48
|
+
/** @private */
|
49
|
+
pv.Layout.Tree.prototype.buildImplied = function(s) {
|
50
|
+
if (pv.Layout.Hierarchy.prototype.buildImplied.call(this, s)) return;
|
51
|
+
|
52
|
+
var nodes = s.nodes,
|
53
|
+
orient = s.orient,
|
54
|
+
depth = s.depth,
|
55
|
+
breadth = s.breadth,
|
56
|
+
group = s.group,
|
57
|
+
w = s.width,
|
58
|
+
h = s.height;
|
59
|
+
|
60
|
+
/** @private */
|
61
|
+
function firstWalk(v) {
|
62
|
+
var l, r, a;
|
63
|
+
if (!v.firstChild) {
|
64
|
+
if (l = v.previousSibling) {
|
65
|
+
v.prelim = l.prelim + distance(v.depth, true);
|
66
|
+
}
|
67
|
+
} else {
|
68
|
+
l = v.firstChild;
|
69
|
+
r = v.lastChild;
|
70
|
+
a = l; // default ancestor
|
71
|
+
for (var c = l; c; c = c.nextSibling) {
|
72
|
+
firstWalk(c);
|
73
|
+
a = apportion(c, a);
|
74
|
+
}
|
75
|
+
executeShifts(v);
|
76
|
+
var midpoint = .5 * (l.prelim + r.prelim);
|
77
|
+
if (l = v.previousSibling) {
|
78
|
+
v.prelim = l.prelim + distance(v.depth, true);
|
79
|
+
v.mod = v.prelim - midpoint;
|
80
|
+
} else {
|
81
|
+
v.prelim = midpoint;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
/** @private */
|
87
|
+
function secondWalk(v, m, depth) {
|
88
|
+
v.breadth = v.prelim + m;
|
89
|
+
m += v.mod;
|
90
|
+
for (var c = v.firstChild; c; c = c.nextSibling) {
|
91
|
+
secondWalk(c, m, depth);
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
/** @private */
|
96
|
+
function apportion(v, a) {
|
97
|
+
var w = v.previousSibling;
|
98
|
+
if (w) {
|
99
|
+
var vip = v,
|
100
|
+
vop = v,
|
101
|
+
vim = w,
|
102
|
+
vom = v.parentNode.firstChild,
|
103
|
+
sip = vip.mod,
|
104
|
+
sop = vop.mod,
|
105
|
+
sim = vim.mod,
|
106
|
+
som = vom.mod,
|
107
|
+
nr = nextRight(vim),
|
108
|
+
nl = nextLeft(vip);
|
109
|
+
while (nr && nl) {
|
110
|
+
vim = nr;
|
111
|
+
vip = nl;
|
112
|
+
vom = nextLeft(vom);
|
113
|
+
vop = nextRight(vop);
|
114
|
+
vop.ancestor = v;
|
115
|
+
var shift = (vim.prelim + sim) - (vip.prelim + sip) + distance(vim.depth, false);
|
116
|
+
if (shift > 0) {
|
117
|
+
moveSubtree(ancestor(vim, v, a), v, shift);
|
118
|
+
sip += shift;
|
119
|
+
sop += shift;
|
120
|
+
}
|
121
|
+
sim += vim.mod;
|
122
|
+
sip += vip.mod;
|
123
|
+
som += vom.mod;
|
124
|
+
sop += vop.mod;
|
125
|
+
nr = nextRight(vim);
|
126
|
+
nl = nextLeft(vip);
|
127
|
+
}
|
128
|
+
if (nr && !nextRight(vop)) {
|
129
|
+
vop.thread = nr;
|
130
|
+
vop.mod += sim - sop;
|
131
|
+
}
|
132
|
+
if (nl && !nextLeft(vom)) {
|
133
|
+
vom.thread = nl;
|
134
|
+
vom.mod += sip - som;
|
135
|
+
a = v;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
return a;
|
139
|
+
}
|
140
|
+
|
141
|
+
/** @private */
|
142
|
+
function nextLeft(v) {
|
143
|
+
return v.firstChild || v.thread;
|
144
|
+
}
|
145
|
+
|
146
|
+
/** @private */
|
147
|
+
function nextRight(v) {
|
148
|
+
return v.lastChild || v.thread;
|
149
|
+
}
|
150
|
+
|
151
|
+
/** @private */
|
152
|
+
function moveSubtree(wm, wp, shift) {
|
153
|
+
var subtrees = wp.number - wm.number;
|
154
|
+
wp.change -= shift / subtrees;
|
155
|
+
wp.shift += shift;
|
156
|
+
wm.change += shift / subtrees;
|
157
|
+
wp.prelim += shift;
|
158
|
+
wp.mod += shift;
|
159
|
+
}
|
160
|
+
|
161
|
+
/** @private */
|
162
|
+
function executeShifts(v) {
|
163
|
+
var shift = 0, change = 0;
|
164
|
+
for (var c = v.lastChild; c; c = c.previousSibling) {
|
165
|
+
c.prelim += shift;
|
166
|
+
c.mod += shift;
|
167
|
+
change += c.change;
|
168
|
+
shift += c.shift + change;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
/** @private */
|
173
|
+
function ancestor(vim, v, a) {
|
174
|
+
return (vim.ancestor.parentNode == v.parentNode) ? vim.ancestor : a;
|
175
|
+
}
|
176
|
+
|
177
|
+
/** @private */
|
178
|
+
function distance(depth, siblings) {
|
179
|
+
return (siblings ? 1 : (group + 1)) / ((orient == "radial") ? depth : 1);
|
180
|
+
}
|
181
|
+
|
182
|
+
/* Initialize temporary layout variables. TODO: store separately. */
|
183
|
+
var root = nodes[0];
|
184
|
+
root.visitAfter(function(v, i) {
|
185
|
+
v.ancestor = v;
|
186
|
+
v.prelim = 0;
|
187
|
+
v.mod = 0;
|
188
|
+
v.change = 0;
|
189
|
+
v.shift = 0;
|
190
|
+
v.number = v.previousSibling ? (v.previousSibling.number + 1) : 0;
|
191
|
+
v.depth = i;
|
192
|
+
});
|
193
|
+
|
194
|
+
/* Compute the layout using Buchheim et al.'s algorithm. */
|
195
|
+
firstWalk(root);
|
196
|
+
secondWalk(root, -root.prelim, 0);
|
197
|
+
|
198
|
+
/** @private Returns the angle of the given node. */
|
199
|
+
function midAngle(n) {
|
200
|
+
return (orient == "radial") ? n.breadth / depth : 0;
|
201
|
+
}
|
202
|
+
|
203
|
+
/** @private */
|
204
|
+
function x(n) {
|
205
|
+
switch (orient) {
|
206
|
+
case "left": return n.depth;
|
207
|
+
case "right": return w - n.depth;
|
208
|
+
case "top":
|
209
|
+
case "bottom": return n.breadth + w / 2;
|
210
|
+
case "radial": return w / 2 + n.depth * Math.cos(midAngle(n));
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
/** @private */
|
215
|
+
function y(n) {
|
216
|
+
switch (orient) {
|
217
|
+
case "left":
|
218
|
+
case "right": return n.breadth + h / 2;
|
219
|
+
case "top": return n.depth;
|
220
|
+
case "bottom": return h - n.depth;
|
221
|
+
case "radial": return h / 2 + n.depth * Math.sin(midAngle(n));
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
/* Clear temporary layout variables; transform depth and breadth. */
|
226
|
+
root.visitAfter(function(v) {
|
227
|
+
v.breadth *= breadth;
|
228
|
+
v.depth *= depth;
|
229
|
+
v.midAngle = midAngle(v);
|
230
|
+
v.x = x(v);
|
231
|
+
v.y = y(v);
|
232
|
+
if (v.firstChild) v.midAngle += Math.PI;
|
233
|
+
delete v.breadth;
|
234
|
+
delete v.depth;
|
235
|
+
delete v.ancestor;
|
236
|
+
delete v.prelim;
|
237
|
+
delete v.mod;
|
238
|
+
delete v.change;
|
239
|
+
delete v.shift;
|
240
|
+
delete v.number;
|
241
|
+
delete v.thread;
|
242
|
+
});
|
243
|
+
};
|
244
|
+
|
245
|
+
/**
|
246
|
+
* The offset between siblings nodes; defaults to 15.
|
247
|
+
*
|
248
|
+
* @type number
|
249
|
+
* @name pv.Layout.Tree.prototype.breadth
|
250
|
+
*/
|
251
|
+
|
252
|
+
/**
|
253
|
+
* The offset between parent and child nodes; defaults to 60.
|
254
|
+
*
|
255
|
+
* @type number
|
256
|
+
* @name pv.Layout.Tree.prototype.depth
|
257
|
+
*/
|
258
|
+
|
259
|
+
/**
|
260
|
+
* The orientation. The default orientation is "top", which means that the root
|
261
|
+
* node is placed on the top edge, leaf nodes appear at the bottom, and internal
|
262
|
+
* nodes are in-between. The following orientations are supported:<ul>
|
263
|
+
*
|
264
|
+
* <li>left - left-to-right.
|
265
|
+
* <li>right - right-to-left.
|
266
|
+
* <li>top - top-to-bottom.
|
267
|
+
* <li>bottom - bottom-to-top.
|
268
|
+
* <li>radial - radially, with the root at the center.</ul>
|
269
|
+
*
|
270
|
+
* @type string
|
271
|
+
* @name pv.Layout.Tree.prototype.orient
|
272
|
+
*/
|
273
|
+
|
274
|
+
/**
|
275
|
+
* The sibling grouping, i.e., whether differentiating space is placed between
|
276
|
+
* sibling groups. The default is 1 (or true), causing sibling leaves to be
|
277
|
+
* separated by one breadth offset. Setting this to false (or 0) causes
|
278
|
+
* non-siblings to be adjacent.
|
279
|
+
*
|
280
|
+
* @type number
|
281
|
+
* @name pv.Layout.Tree.prototype.group
|
282
|
+
*/
|
@@ -0,0 +1,347 @@
|
|
1
|
+
/**
|
2
|
+
* Constructs a new, empty treemap layout. Layouts are not typically
|
3
|
+
* constructed directly; instead, they are added to an existing panel via
|
4
|
+
* {@link pv.Mark#add}.
|
5
|
+
*
|
6
|
+
* @class Implements a space-filling rectangular layout, with the hierarchy
|
7
|
+
* represented via containment. Treemaps represent nodes as boxes, with child
|
8
|
+
* nodes placed within parent boxes. The size of each box is proportional to the
|
9
|
+
* size of the node in the tree. This particular algorithm is taken from Bruls,
|
10
|
+
* D.M., C. Huizing, and J.J. van Wijk, <a
|
11
|
+
* href="http://www.win.tue.nl/~vanwijk/stm.pdf">"Squarified Treemaps"</a> in
|
12
|
+
* <i>Data Visualization 2000, Proceedings of the Joint Eurographics and IEEE
|
13
|
+
* TCVG Sumposium on Visualization</i>, 2000, pp. 33-42.
|
14
|
+
*
|
15
|
+
* <p>The meaning of the exported mark prototypes changes slightly in the
|
16
|
+
* space-filling implementation:<ul>
|
17
|
+
*
|
18
|
+
* <li><tt>node</tt> - for rendering nodes; typically a {@link pv.Bar}. The node
|
19
|
+
* data is populated with <tt>dx</tt> and <tt>dy</tt> attributes, in addition to
|
20
|
+
* the standard <tt>x</tt> and <tt>y</tt> position attributes.
|
21
|
+
*
|
22
|
+
* <p><li><tt>leaf</tt> - for rendering leaf nodes only, with no fill or stroke
|
23
|
+
* style by default; typically a {@link pv.Panel} or another layout!
|
24
|
+
*
|
25
|
+
* <p><li><tt>link</tt> - unsupported; undefined. Links are encoded implicitly
|
26
|
+
* in the arrangement of the space-filling nodes.
|
27
|
+
*
|
28
|
+
* <p><li><tt>label</tt> - for rendering node labels; typically a
|
29
|
+
* {@link pv.Label}.
|
30
|
+
*
|
31
|
+
* </ul>For more details on how to use this layout, see
|
32
|
+
* {@link pv.Layout.Hierarchy}.
|
33
|
+
*
|
34
|
+
* @extends pv.Layout.Hierarchy
|
35
|
+
*/
|
36
|
+
pv.Layout.Treemap = function() {
|
37
|
+
pv.Layout.Hierarchy.call(this);
|
38
|
+
|
39
|
+
this.node
|
40
|
+
.strokeStyle("#fff")
|
41
|
+
.fillStyle("rgba(31, 119, 180, .25)")
|
42
|
+
.width(function(n) { return n.dx; })
|
43
|
+
.height(function(n) { return n.dy; });
|
44
|
+
|
45
|
+
this.label
|
46
|
+
.visible(function(n) { return !n.firstChild; })
|
47
|
+
.left(function(n) { return n.x + (n.dx / 2); })
|
48
|
+
.top(function(n) { return n.y + (n.dy / 2); })
|
49
|
+
.textAlign("center")
|
50
|
+
.textAngle(function(n) { return n.dx > n.dy ? 0 : -Math.PI / 2; });
|
51
|
+
|
52
|
+
(this.leaf = new pv.Mark()
|
53
|
+
.extend(this.node)
|
54
|
+
.fillStyle(null)
|
55
|
+
.strokeStyle(null)
|
56
|
+
.visible(function(n) { return !n.firstChild; })).parent = this;
|
57
|
+
|
58
|
+
/* Hide unsupported link. */
|
59
|
+
delete this.link;
|
60
|
+
};
|
61
|
+
|
62
|
+
pv.Layout.Treemap.prototype = pv.extend(pv.Layout.Hierarchy)
|
63
|
+
.property("round", Boolean)
|
64
|
+
.property("paddingLeft", Number)
|
65
|
+
.property("paddingRight", Number)
|
66
|
+
.property("paddingTop", Number)
|
67
|
+
.property("paddingBottom", Number)
|
68
|
+
.property("mode", String)
|
69
|
+
.property("order", String);
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Default propertiess for treemap layouts. The default mode is "squarify" and
|
73
|
+
* the default order is "ascending".
|
74
|
+
*
|
75
|
+
* @type pv.Layout.Treemap
|
76
|
+
*/
|
77
|
+
pv.Layout.Treemap.prototype.defaults = new pv.Layout.Treemap()
|
78
|
+
.extend(pv.Layout.Hierarchy.prototype.defaults)
|
79
|
+
.mode("squarify") // squarify, slice-and-dice, slice, dice
|
80
|
+
.order("ascending"); // ascending, descending, reverse, null
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Whether node sizes should be rounded to integer values. This has a similar
|
84
|
+
* effect to setting <tt>antialias(false)</tt> for node values, but allows the
|
85
|
+
* treemap algorithm to accumulate error related to pixel rounding.
|
86
|
+
*
|
87
|
+
* @type boolean
|
88
|
+
* @name pv.Layout.Treemap.prototype.round
|
89
|
+
*/
|
90
|
+
|
91
|
+
/**
|
92
|
+
* The left inset between parent add child in pixels. Defaults to 0.
|
93
|
+
*
|
94
|
+
* @type number
|
95
|
+
* @name pv.Layout.Treemap.prototype.paddingLeft
|
96
|
+
* @see #padding
|
97
|
+
*/
|
98
|
+
|
99
|
+
/**
|
100
|
+
* The right inset between parent add child in pixels. Defaults to 0.
|
101
|
+
*
|
102
|
+
* @type number
|
103
|
+
* @name pv.Layout.Treemap.prototype.paddingRight
|
104
|
+
* @see #padding
|
105
|
+
*/
|
106
|
+
|
107
|
+
/**
|
108
|
+
* The top inset between parent and child in pixels. Defaults to 0.
|
109
|
+
*
|
110
|
+
* @type number
|
111
|
+
* @name pv.Layout.Treemap.prototype.paddingTop
|
112
|
+
* @see #padding
|
113
|
+
*/
|
114
|
+
|
115
|
+
/**
|
116
|
+
* The bottom inset between parent and child in pixels. Defaults to 0.
|
117
|
+
*
|
118
|
+
* @type number
|
119
|
+
* @name pv.Layout.Treemap.prototype.paddingBottom
|
120
|
+
* @see #padding
|
121
|
+
*/
|
122
|
+
|
123
|
+
/**
|
124
|
+
* The treemap algorithm. The default value is "squarify". The "slice-and-dice"
|
125
|
+
* algorithm may also be used, which alternates between horizontal and vertical
|
126
|
+
* slices for different depths. In addition, the "slice" and "dice" algorithms
|
127
|
+
* may be specified explicitly to control whether horizontal or vertical slices
|
128
|
+
* are used, which may be useful for nested treemap layouts.
|
129
|
+
*
|
130
|
+
* @type string
|
131
|
+
* @name pv.Layout.Treemap.prototype.mode
|
132
|
+
* @see <a
|
133
|
+
* href="ftp://ftp.cs.umd.edu/pub/hcil/Reports-Abstracts-Bibliography/2001-06html/2001-06.pdf"
|
134
|
+
* >"Ordered Treemap Layouts"</a> by B. Shneiderman & M. Wattenberg, IEEE
|
135
|
+
* InfoVis 2001.
|
136
|
+
*/
|
137
|
+
|
138
|
+
/**
|
139
|
+
* The sibling node order. A <tt>null</tt> value means to use the sibling order
|
140
|
+
* specified by the nodes property as-is; "reverse" will reverse the given
|
141
|
+
* order. The default value "ascending" will sort siblings in ascending order of
|
142
|
+
* size, while "descending" will do the reverse. For sorting based on data
|
143
|
+
* attributes other than size, use the default <tt>null</tt> for the order
|
144
|
+
* property, and sort the nodes beforehand using the {@link pv.Dom} operator.
|
145
|
+
*
|
146
|
+
* @type string
|
147
|
+
* @name pv.Layout.Treemap.prototype.order
|
148
|
+
*/
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Alias for setting the left, right, top and bottom padding properties
|
152
|
+
* simultaneously.
|
153
|
+
*
|
154
|
+
* @see #paddingLeft
|
155
|
+
* @see #paddingRight
|
156
|
+
* @see #paddingTop
|
157
|
+
* @see #paddingBottom
|
158
|
+
* @returns {pv.Layout.Treemap} this.
|
159
|
+
*/
|
160
|
+
pv.Layout.Treemap.prototype.padding = function(n) {
|
161
|
+
return this.paddingLeft(n).paddingRight(n).paddingTop(n).paddingBottom(n);
|
162
|
+
};
|
163
|
+
|
164
|
+
/** @private The default size function. */
|
165
|
+
pv.Layout.Treemap.prototype.$size = function(d) {
|
166
|
+
return Number(d.nodeValue);
|
167
|
+
};
|
168
|
+
|
169
|
+
/**
|
170
|
+
* Specifies the sizing function. By default, the size function uses the
|
171
|
+
* <tt>nodeValue</tt> attribute of nodes as a numeric value: <tt>function(d)
|
172
|
+
* Number(d.nodeValue)</tt>.
|
173
|
+
*
|
174
|
+
* <p>The sizing function is invoked for each leaf node in the tree, per the
|
175
|
+
* <tt>nodes</tt> property. For example, if the tree data structure represents a
|
176
|
+
* file system, with files as leaf nodes, and each file has a <tt>bytes</tt>
|
177
|
+
* attribute, you can specify a size function as:
|
178
|
+
*
|
179
|
+
* <pre> .size(function(d) d.bytes)</pre>
|
180
|
+
*
|
181
|
+
* @param {function} f the new sizing function.
|
182
|
+
* @returns {pv.Layout.Treemap} this.
|
183
|
+
*/
|
184
|
+
pv.Layout.Treemap.prototype.size = function(f) {
|
185
|
+
this.$size = pv.functor(f);
|
186
|
+
return this;
|
187
|
+
};
|
188
|
+
|
189
|
+
/** @private */
|
190
|
+
pv.Layout.Treemap.prototype.buildImplied = function(s) {
|
191
|
+
if (pv.Layout.Hierarchy.prototype.buildImplied.call(this, s)) return;
|
192
|
+
|
193
|
+
var that = this,
|
194
|
+
nodes = s.nodes,
|
195
|
+
root = nodes[0],
|
196
|
+
stack = pv.Mark.stack,
|
197
|
+
left = s.paddingLeft,
|
198
|
+
right = s.paddingRight,
|
199
|
+
top = s.paddingTop,
|
200
|
+
bottom = s.paddingBottom,
|
201
|
+
/** @ignore */ size = function(n) { return n.size; },
|
202
|
+
round = s.round ? Math.round : Number,
|
203
|
+
mode = s.mode;
|
204
|
+
|
205
|
+
/** @private */
|
206
|
+
function slice(row, sum, horizontal, x, y, w, h) {
|
207
|
+
for (var i = 0, d = 0; i < row.length; i++) {
|
208
|
+
var n = row[i];
|
209
|
+
if (horizontal) {
|
210
|
+
n.x = x + d;
|
211
|
+
n.y = y;
|
212
|
+
d += n.dx = round(w * n.size / sum);
|
213
|
+
n.dy = h;
|
214
|
+
} else {
|
215
|
+
n.x = x;
|
216
|
+
n.y = y + d;
|
217
|
+
n.dx = w;
|
218
|
+
d += n.dy = round(h * n.size / sum);
|
219
|
+
}
|
220
|
+
}
|
221
|
+
if (n) { // correct on-axis rounding error
|
222
|
+
if (horizontal) {
|
223
|
+
n.dx += w - d;
|
224
|
+
} else {
|
225
|
+
n.dy += h - d;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
}
|
229
|
+
|
230
|
+
/** @private */
|
231
|
+
function ratio(row, l) {
|
232
|
+
var rmax = -Infinity, rmin = Infinity, s = 0;
|
233
|
+
for (var i = 0; i < row.length; i++) {
|
234
|
+
var r = row[i].size;
|
235
|
+
if (r < rmin) rmin = r;
|
236
|
+
if (r > rmax) rmax = r;
|
237
|
+
s += r;
|
238
|
+
}
|
239
|
+
s = s * s;
|
240
|
+
l = l * l;
|
241
|
+
return Math.max(l * rmax / s, s / (l * rmin));
|
242
|
+
}
|
243
|
+
|
244
|
+
/** @private */
|
245
|
+
function layout(n, i) {
|
246
|
+
var x = n.x + left,
|
247
|
+
y = n.y + top,
|
248
|
+
w = n.dx - left - right,
|
249
|
+
h = n.dy - top - bottom;
|
250
|
+
|
251
|
+
/* Assume squarify by default. */
|
252
|
+
if (mode != "squarify") {
|
253
|
+
slice(n.childNodes, n.size,
|
254
|
+
mode == "slice" ? true
|
255
|
+
: mode == "dice" ? false
|
256
|
+
: i & 1, x, y, w, h);
|
257
|
+
return;
|
258
|
+
}
|
259
|
+
|
260
|
+
var row = [],
|
261
|
+
mink = Infinity,
|
262
|
+
l = Math.min(w, h),
|
263
|
+
k = w * h / n.size;
|
264
|
+
|
265
|
+
/* Abort if the size is nonpositive. */
|
266
|
+
if (n.size <= 0) return;
|
267
|
+
|
268
|
+
/* Scale the sizes to fill the current subregion. */
|
269
|
+
n.visitBefore(function(n) { n.size *= k; });
|
270
|
+
|
271
|
+
/** @private Position the specified nodes along one dimension. */
|
272
|
+
function position(row) {
|
273
|
+
var horizontal = w == l,
|
274
|
+
sum = pv.sum(row, size),
|
275
|
+
r = l ? round(sum / l) : 0;
|
276
|
+
slice(row, sum, horizontal, x, y, horizontal ? w : r, horizontal ? r : h);
|
277
|
+
if (horizontal) {
|
278
|
+
y += r;
|
279
|
+
h -= r;
|
280
|
+
} else {
|
281
|
+
x += r;
|
282
|
+
w -= r;
|
283
|
+
}
|
284
|
+
l = Math.min(w, h);
|
285
|
+
return horizontal;
|
286
|
+
}
|
287
|
+
|
288
|
+
var children = n.childNodes.slice(); // copy
|
289
|
+
while (children.length) {
|
290
|
+
var child = children[children.length - 1];
|
291
|
+
if (!child.size) {
|
292
|
+
children.pop();
|
293
|
+
continue;
|
294
|
+
}
|
295
|
+
row.push(child);
|
296
|
+
|
297
|
+
var k = ratio(row, l);
|
298
|
+
if (k <= mink) {
|
299
|
+
children.pop();
|
300
|
+
mink = k;
|
301
|
+
} else {
|
302
|
+
row.pop();
|
303
|
+
position(row);
|
304
|
+
row.length = 0;
|
305
|
+
mink = Infinity;
|
306
|
+
}
|
307
|
+
}
|
308
|
+
|
309
|
+
/* correct off-axis rounding error */
|
310
|
+
if (position(row)) for (var i = 0; i < row.length; i++) {
|
311
|
+
row[i].dy += h;
|
312
|
+
} else for (var i = 0; i < row.length; i++) {
|
313
|
+
row[i].dx += w;
|
314
|
+
}
|
315
|
+
}
|
316
|
+
|
317
|
+
/* Recursively compute the node depth and size. */
|
318
|
+
stack.unshift(null);
|
319
|
+
root.visitAfter(function(n, i) {
|
320
|
+
n.depth = i;
|
321
|
+
n.x = n.y = n.dx = n.dy = 0;
|
322
|
+
n.size = n.firstChild
|
323
|
+
? pv.sum(n.childNodes, function(n) { return n.size; })
|
324
|
+
: that.$size.apply(that, (stack[0] = n, stack));
|
325
|
+
});
|
326
|
+
stack.shift();
|
327
|
+
|
328
|
+
/* Sort. */
|
329
|
+
switch (s.order) {
|
330
|
+
case "ascending": {
|
331
|
+
root.sort(function(a, b) { return a.size - b.size; });
|
332
|
+
break;
|
333
|
+
}
|
334
|
+
case "descending": {
|
335
|
+
root.sort(function(a, b) { return b.size - a.size; });
|
336
|
+
break;
|
337
|
+
}
|
338
|
+
case "reverse": root.reverse(); break;
|
339
|
+
}
|
340
|
+
|
341
|
+
/* Recursively compute the layout. */
|
342
|
+
root.x = 0;
|
343
|
+
root.y = 0;
|
344
|
+
root.dx = s.width;
|
345
|
+
root.dy = s.height;
|
346
|
+
root.visitBefore(layout);
|
347
|
+
};
|