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,164 @@
|
|
1
|
+
// ranges (bad, satisfactory, good)
|
2
|
+
// measures (actual, forecast)
|
3
|
+
// markers (previous, goal)
|
4
|
+
|
5
|
+
/*
|
6
|
+
* Chart design based on the recommendations of Stephen Few. Implementation
|
7
|
+
* based on the work of Clint Ivy, Jamie Love, and Jason Davies.
|
8
|
+
* http://projects.instantcognition.com/protovis/bulletchart/
|
9
|
+
*/
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Constructs a new, empty bullet layout. Layouts are not typically constructed
|
13
|
+
* directly; instead, they are added to an existing panel via
|
14
|
+
* {@link pv.Mark#add}.
|
15
|
+
*
|
16
|
+
* @class
|
17
|
+
* @extends pv.Layout
|
18
|
+
*/
|
19
|
+
pv.Layout.Bullet = function() {
|
20
|
+
pv.Layout.call(this);
|
21
|
+
var that = this,
|
22
|
+
buildImplied = that.buildImplied,
|
23
|
+
scale = that.x = pv.Scale.linear(),
|
24
|
+
orient,
|
25
|
+
horizontal,
|
26
|
+
rangeColor,
|
27
|
+
measureColor,
|
28
|
+
x;
|
29
|
+
|
30
|
+
/** @private Cache layout state to optimize properties. */
|
31
|
+
this.buildImplied = function(s) {
|
32
|
+
buildImplied.call(this, x = s);
|
33
|
+
orient = s.orient;
|
34
|
+
horizontal = /^left|right$/.test(orient);
|
35
|
+
rangeColor = pv.ramp("#bbb", "#eee")
|
36
|
+
.domain(0, Math.max(1, x.ranges.length - 1));
|
37
|
+
measureColor = pv.ramp("steelblue", "lightsteelblue")
|
38
|
+
.domain(0, Math.max(1, x.measures.length - 1));
|
39
|
+
};
|
40
|
+
|
41
|
+
/**
|
42
|
+
* The range prototype.
|
43
|
+
*
|
44
|
+
* @type pv.Mark
|
45
|
+
* @name pv.Layout.Bullet.prototype.range
|
46
|
+
*/
|
47
|
+
(this.range = new pv.Mark())
|
48
|
+
.data(function() { return x.ranges; })
|
49
|
+
.reverse(true)
|
50
|
+
.left(function() { return orient == "left" ? 0 : null; })
|
51
|
+
.top(function() { return orient == "top" ? 0 : null; })
|
52
|
+
.right(function() { return orient == "right" ? 0 : null; })
|
53
|
+
.bottom(function() { return orient == "bottom" ? 0 : null; })
|
54
|
+
.width(function(d) { return horizontal ? scale(d) : null; })
|
55
|
+
.height(function(d) { return horizontal ? null : scale(d); })
|
56
|
+
.fillStyle(function() { return rangeColor(this.index); })
|
57
|
+
.antialias(false)
|
58
|
+
.parent = that;
|
59
|
+
|
60
|
+
/**
|
61
|
+
* The measure prototype.
|
62
|
+
*
|
63
|
+
* @type pv.Mark
|
64
|
+
* @name pv.Layout.Bullet.prototype.measure
|
65
|
+
*/
|
66
|
+
(this.measure = new pv.Mark())
|
67
|
+
.extend(this.range)
|
68
|
+
.data(function() { return x.measures; })
|
69
|
+
.left(function() { return orient == "left" ? 0 : horizontal ? null : this.parent.width() / 3.25; })
|
70
|
+
.top(function() { return orient == "top" ? 0 : horizontal ? this.parent.height() / 3.25 : null; })
|
71
|
+
.right(function() { return orient == "right" ? 0 : horizontal ? null : this.parent.width() / 3.25; })
|
72
|
+
.bottom(function() { return orient == "bottom" ? 0 : horizontal ? this.parent.height() / 3.25 : null; })
|
73
|
+
.fillStyle(function() { return measureColor(this.index); })
|
74
|
+
.parent = that;
|
75
|
+
|
76
|
+
/**
|
77
|
+
* The marker prototype.
|
78
|
+
*
|
79
|
+
* @type pv.Mark
|
80
|
+
* @name pv.Layout.Bullet.prototype.marker
|
81
|
+
*/
|
82
|
+
(this.marker = new pv.Mark())
|
83
|
+
.data(function() { return x.markers; })
|
84
|
+
.left(function(d) { return orient == "left" ? scale(d) : horizontal ? null : this.parent.width() / 2; })
|
85
|
+
.top(function(d) { return orient == "top" ? scale(d) : horizontal ? this.parent.height() / 2 : null; })
|
86
|
+
.right(function(d) { return orient == "right" ? scale(d) : null; })
|
87
|
+
.bottom(function(d) { return orient == "bottom" ? scale(d) : null; })
|
88
|
+
.strokeStyle("black")
|
89
|
+
.shape("bar")
|
90
|
+
.shapeAngle(function() { return horizontal ? 0 : Math.PI / 2; })
|
91
|
+
.parent = that;
|
92
|
+
|
93
|
+
(this.tick = new pv.Mark())
|
94
|
+
.data(function() { return scale.ticks(7); })
|
95
|
+
.left(function(d) { return orient == "left" ? scale(d) : null; })
|
96
|
+
.top(function(d) { return orient == "top" ? scale(d) : null; })
|
97
|
+
.right(function(d) { return orient == "right" ? scale(d) : horizontal ? null : -6; })
|
98
|
+
.bottom(function(d) { return orient == "bottom" ? scale(d) : horizontal ? -8 : null; })
|
99
|
+
.height(function() { return horizontal ? 6 : null; })
|
100
|
+
.width(function() { return horizontal ? null : 6; })
|
101
|
+
.parent = that;
|
102
|
+
};
|
103
|
+
|
104
|
+
pv.Layout.Bullet.prototype = pv.extend(pv.Layout)
|
105
|
+
.property("orient", String) // left, right, top, bottom
|
106
|
+
.property("ranges")
|
107
|
+
.property("markers")
|
108
|
+
.property("measures")
|
109
|
+
.property("maximum", Number);
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Default properties for bullet layouts.
|
113
|
+
*
|
114
|
+
* @type pv.Layout.Bullet
|
115
|
+
*/
|
116
|
+
pv.Layout.Bullet.prototype.defaults = new pv.Layout.Bullet()
|
117
|
+
.extend(pv.Layout.prototype.defaults)
|
118
|
+
.orient("left")
|
119
|
+
.ranges([])
|
120
|
+
.markers([])
|
121
|
+
.measures([]);
|
122
|
+
|
123
|
+
/**
|
124
|
+
* The orientation.
|
125
|
+
*
|
126
|
+
* @type string
|
127
|
+
* @name pv.Layout.Bullet.prototype.orient
|
128
|
+
*/
|
129
|
+
|
130
|
+
/**
|
131
|
+
* The array of range values.
|
132
|
+
*
|
133
|
+
* @type array
|
134
|
+
* @name pv.Layout.Bullet.prototype.ranges
|
135
|
+
*/
|
136
|
+
|
137
|
+
/**
|
138
|
+
* The array of marker values.
|
139
|
+
*
|
140
|
+
* @type array
|
141
|
+
* @name pv.Layout.Bullet.prototype.markers
|
142
|
+
*/
|
143
|
+
|
144
|
+
/**
|
145
|
+
* The array of measure values.
|
146
|
+
*
|
147
|
+
* @type array
|
148
|
+
* @name pv.Layout.Bullet.prototype.measures
|
149
|
+
*/
|
150
|
+
|
151
|
+
/**
|
152
|
+
* Optional; the maximum range value.
|
153
|
+
*
|
154
|
+
* @type number
|
155
|
+
* @name pv.Layout.Bullet.prototype.maximum
|
156
|
+
*/
|
157
|
+
|
158
|
+
/** @private */
|
159
|
+
pv.Layout.Bullet.prototype.buildImplied = function(s) {
|
160
|
+
pv.Layout.prototype.buildImplied.call(this, s);
|
161
|
+
var size = this.parent[/^left|right$/.test(s.orient) ? "width" : "height"]();
|
162
|
+
s.maximum = s.maximum || pv.max([].concat(s.ranges, s.markers, s.measures));
|
163
|
+
this.x.domain(0, s.maximum).range(0, size);
|
164
|
+
};
|
@@ -0,0 +1,205 @@
|
|
1
|
+
/**
|
2
|
+
* Constructs a new, empty cluster 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 hierarchical layout using the cluster (or dendrogram)
|
7
|
+
* algorithm. This layout provides both node-link and space-filling
|
8
|
+
* implementations of cluster diagrams. In many ways it is similar to
|
9
|
+
* {@link pv.Layout.Partition}, except that leaf nodes are positioned at maximum
|
10
|
+
* depth, and the depth of internal nodes is based on their distance from their
|
11
|
+
* deepest descendant, rather than their distance from the root.
|
12
|
+
*
|
13
|
+
* <p>The cluster layout supports a "group" property, which if true causes
|
14
|
+
* siblings to be positioned closer together than unrelated nodes at the same
|
15
|
+
* depth. Unlike the partition layout, this layout does not support dynamic
|
16
|
+
* sizing for leaf nodes; all leaf nodes are the same size.
|
17
|
+
*
|
18
|
+
* <p>For more details on how to use this layout, see
|
19
|
+
* {@link pv.Layout.Hierarchy}.
|
20
|
+
*
|
21
|
+
* @see pv.Layout.Cluster.Fill
|
22
|
+
* @extends pv.Layout.Hierarchy
|
23
|
+
*/
|
24
|
+
pv.Layout.Cluster = function() {
|
25
|
+
pv.Layout.Hierarchy.call(this);
|
26
|
+
var interpolate, // cached interpolate
|
27
|
+
buildImplied = this.buildImplied;
|
28
|
+
|
29
|
+
/** @private Cache layout state to optimize properties. */
|
30
|
+
this.buildImplied = function(s) {
|
31
|
+
buildImplied.call(this, s);
|
32
|
+
interpolate
|
33
|
+
= /^(top|bottom)$/.test(s.orient) ? "step-before"
|
34
|
+
: /^(left|right)$/.test(s.orient) ? "step-after"
|
35
|
+
: "linear";
|
36
|
+
};
|
37
|
+
|
38
|
+
this.link.interpolate(function() { return interpolate; });
|
39
|
+
};
|
40
|
+
|
41
|
+
pv.Layout.Cluster.prototype = pv.extend(pv.Layout.Hierarchy)
|
42
|
+
.property("group", Number)
|
43
|
+
.property("orient", String)
|
44
|
+
.property("innerRadius", Number)
|
45
|
+
.property("outerRadius", Number);
|
46
|
+
|
47
|
+
/**
|
48
|
+
* The group parameter; defaults to 0, disabling grouping of siblings. If this
|
49
|
+
* parameter is set to a positive number (or true, which is equivalent to 1),
|
50
|
+
* then additional space will be allotted between sibling groups. In other
|
51
|
+
* words, siblings (nodes that share the same parent) will be positioned more
|
52
|
+
* closely than nodes at the same depth that do not share a parent.
|
53
|
+
*
|
54
|
+
* @type number
|
55
|
+
* @name pv.Layout.Cluster.prototype.group
|
56
|
+
*/
|
57
|
+
|
58
|
+
/**
|
59
|
+
* The orientation. The default orientation is "top", which means that the root
|
60
|
+
* node is placed on the top edge, leaf nodes appear on the bottom edge, and
|
61
|
+
* internal nodes are in-between. The following orientations are supported:<ul>
|
62
|
+
*
|
63
|
+
* <li>left - left-to-right.
|
64
|
+
* <li>right - right-to-left.
|
65
|
+
* <li>top - top-to-bottom.
|
66
|
+
* <li>bottom - bottom-to-top.
|
67
|
+
* <li>radial - radially, with the root at the center.</ul>
|
68
|
+
*
|
69
|
+
* @type string
|
70
|
+
* @name pv.Layout.Cluster.prototype.orient
|
71
|
+
*/
|
72
|
+
|
73
|
+
/**
|
74
|
+
* The inner radius; defaults to 0. This property applies only to radial
|
75
|
+
* orientations, and can be used to compress the layout radially. Note that for
|
76
|
+
* the node-link implementation, the root node is always at the center,
|
77
|
+
* regardless of the value of this property; this property only affects internal
|
78
|
+
* and leaf nodes. For the space-filling implementation, a non-zero value of
|
79
|
+
* this property will result in the root node represented as a ring rather than
|
80
|
+
* a circle.
|
81
|
+
*
|
82
|
+
* @type number
|
83
|
+
* @name pv.Layout.Cluster.prototype.innerRadius
|
84
|
+
*/
|
85
|
+
|
86
|
+
/**
|
87
|
+
* The outer radius; defaults to fill the containing panel, based on the height
|
88
|
+
* and width of the layout. If the layout has no height and width specified, it
|
89
|
+
* will extend to fill the enclosing panel.
|
90
|
+
*
|
91
|
+
* @type number
|
92
|
+
* @name pv.Layout.Cluster.prototype.outerRadius
|
93
|
+
*/
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Defaults for cluster layouts. The default group parameter is 0 and the
|
97
|
+
* default orientation is "top".
|
98
|
+
*
|
99
|
+
* @type pv.Layout.Cluster
|
100
|
+
*/
|
101
|
+
pv.Layout.Cluster.prototype.defaults = new pv.Layout.Cluster()
|
102
|
+
.extend(pv.Layout.Hierarchy.prototype.defaults)
|
103
|
+
.group(0)
|
104
|
+
.orient("top");
|
105
|
+
|
106
|
+
/** @private */
|
107
|
+
pv.Layout.Cluster.prototype.buildImplied = function(s) {
|
108
|
+
if (pv.Layout.Hierarchy.prototype.buildImplied.call(this, s)) return;
|
109
|
+
|
110
|
+
var root = s.nodes[0],
|
111
|
+
group = s.group,
|
112
|
+
breadth,
|
113
|
+
depth,
|
114
|
+
leafCount = 0,
|
115
|
+
leafIndex = .5 - group / 2;
|
116
|
+
|
117
|
+
/* Count the leaf nodes and compute the depth of descendants. */
|
118
|
+
var p = undefined;
|
119
|
+
root.visitAfter(function(n) {
|
120
|
+
if (n.firstChild) {
|
121
|
+
n.depth = 1 + pv.max(n.childNodes, function(n) { return n.depth; });
|
122
|
+
} else {
|
123
|
+
if (group && (p != n.parentNode)) {
|
124
|
+
p = n.parentNode;
|
125
|
+
leafCount += group;
|
126
|
+
}
|
127
|
+
leafCount++;
|
128
|
+
n.depth = 0;
|
129
|
+
}
|
130
|
+
});
|
131
|
+
breadth = 1 / leafCount;
|
132
|
+
depth = 1 / root.depth;
|
133
|
+
|
134
|
+
/* Compute the unit breadth and depth of each node. */
|
135
|
+
var p = undefined;
|
136
|
+
root.visitAfter(function(n) {
|
137
|
+
if (n.firstChild) {
|
138
|
+
n.breadth = pv.mean(n.childNodes, function(n) { return n.breadth; });
|
139
|
+
} else {
|
140
|
+
if (group && (p != n.parentNode)) {
|
141
|
+
p = n.parentNode;
|
142
|
+
leafIndex += group;
|
143
|
+
}
|
144
|
+
n.breadth = breadth * leafIndex++;
|
145
|
+
}
|
146
|
+
n.depth = 1 - n.depth * depth;
|
147
|
+
});
|
148
|
+
|
149
|
+
/* Compute breadth and depth ranges for space-filling layouts. */
|
150
|
+
root.visitAfter(function(n) {
|
151
|
+
n.minBreadth = n.firstChild
|
152
|
+
? n.firstChild.minBreadth
|
153
|
+
: (n.breadth - breadth / 2);
|
154
|
+
n.maxBreadth = n.firstChild
|
155
|
+
? n.lastChild.maxBreadth
|
156
|
+
: (n.breadth + breadth / 2);
|
157
|
+
});
|
158
|
+
root.visitBefore(function(n) {
|
159
|
+
n.minDepth = n.parentNode
|
160
|
+
? n.parentNode.maxDepth
|
161
|
+
: 0;
|
162
|
+
n.maxDepth = n.parentNode
|
163
|
+
? (n.depth + root.depth)
|
164
|
+
: (n.minDepth + 2 * root.depth);
|
165
|
+
});
|
166
|
+
root.minDepth = -depth;
|
167
|
+
|
168
|
+
pv.Layout.Hierarchy.NodeLink.buildImplied.call(this, s);
|
169
|
+
};
|
170
|
+
|
171
|
+
/**
|
172
|
+
* Constructs a new, empty space-filling cluster layout. Layouts are not
|
173
|
+
* typically constructed directly; instead, they are added to an existing panel
|
174
|
+
* via {@link pv.Mark#add}.
|
175
|
+
*
|
176
|
+
* @class A variant of cluster layout that is space-filling. The meaning of the
|
177
|
+
* exported mark prototypes changes slightly in the space-filling
|
178
|
+
* implementation:<ul>
|
179
|
+
*
|
180
|
+
* <li><tt>node</tt> - for rendering nodes; typically a {@link pv.Bar} for
|
181
|
+
* non-radial orientations, and a {@link pv.Wedge} for radial orientations.
|
182
|
+
*
|
183
|
+
* <p><li><tt>link</tt> - unsupported; undefined. Links are encoded implicitly
|
184
|
+
* in the arrangement of the space-filling nodes.
|
185
|
+
*
|
186
|
+
* <p><li><tt>label</tt> - for rendering node labels; typically a
|
187
|
+
* {@link pv.Label}.
|
188
|
+
*
|
189
|
+
* </ul>For more details on how to use this layout, see
|
190
|
+
* {@link pv.Layout.Cluster}.
|
191
|
+
*
|
192
|
+
* @extends pv.Layout.Cluster
|
193
|
+
*/
|
194
|
+
pv.Layout.Cluster.Fill = function() {
|
195
|
+
pv.Layout.Cluster.call(this);
|
196
|
+
pv.Layout.Hierarchy.Fill.constructor.call(this);
|
197
|
+
};
|
198
|
+
|
199
|
+
pv.Layout.Cluster.Fill.prototype = pv.extend(pv.Layout.Cluster);
|
200
|
+
|
201
|
+
/** @private */
|
202
|
+
pv.Layout.Cluster.Fill.prototype.buildImplied = function(s) {
|
203
|
+
if (pv.Layout.Cluster.prototype.buildImplied.call(this, s)) return;
|
204
|
+
pv.Layout.Hierarchy.Fill.buildImplied.call(this, s);
|
205
|
+
};
|
@@ -0,0 +1,309 @@
|
|
1
|
+
/**
|
2
|
+
* Constructs a new, empty force-directed 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 force-directed network layout as a node-link diagram. This
|
7
|
+
* layout uses the Fruchterman-Reingold algorithm, which applies an attractive
|
8
|
+
* spring force between neighboring nodes, and a repulsive electrical charge
|
9
|
+
* force between all nodes. An additional drag force improves stability of the
|
10
|
+
* simulation. See {@link pv.Force.spring}, {@link pv.Force.drag} and {@link
|
11
|
+
* pv.Force.charge} for more details; note that the n-body charge force is
|
12
|
+
* approximated using the Barnes-Hut algorithm.
|
13
|
+
*
|
14
|
+
* <p>This layout is implemented on top of {@link pv.Simulation}, which can be
|
15
|
+
* used directly for more control over simulation parameters. The simulation
|
16
|
+
* uses Position Verlet integration, which does not compute velocities
|
17
|
+
* explicitly, but allows for easy geometric constraints, such as bounding the
|
18
|
+
* nodes within the layout panel. Many of the configuration properties supported
|
19
|
+
* by this layout are simply passed through to the underlying forces and
|
20
|
+
* constraints of the simulation.
|
21
|
+
*
|
22
|
+
* <p>Force layouts are typically interactive. The gradual movement of the nodes
|
23
|
+
* as they stabilize to a local stress minimum can help reveal the structure of
|
24
|
+
* the network, as can {@link pv.Behavior.drag}, which allows the user to pick
|
25
|
+
* up nodes and reposition them while the physics simulation continues. This
|
26
|
+
* layout can also be used with pan & zoom behaviors for interaction.
|
27
|
+
*
|
28
|
+
* <p>To facilitate interaction, this layout by default automatically re-renders
|
29
|
+
* using a <tt>setInterval</tt> every 42 milliseconds. This can be disabled via
|
30
|
+
* the <tt>iterations</tt> property, which if non-null specifies the number of
|
31
|
+
* simulation iterations to run before the force-directed layout is finalized.
|
32
|
+
* Be careful not to use too high an iteration count, as this can lead to an
|
33
|
+
* annoying delay on page load.
|
34
|
+
*
|
35
|
+
* <p>As with other network layouts, the network data can be updated
|
36
|
+
* dynamically, provided the property cache is reset. See
|
37
|
+
* {@link pv.Layout.Network} for details. New nodes are initialized with random
|
38
|
+
* positions near the center. Alternatively, positions can be specified manually
|
39
|
+
* by setting the <tt>x</tt> and <tt>y</tt> attributes on nodes.
|
40
|
+
*
|
41
|
+
* @extends pv.Layout.Network
|
42
|
+
* @see <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.13.8444&rep=rep1&type=pdf"
|
43
|
+
* >"Graph Drawing by Force-directed Placement"</a> by T. Fruchterman &
|
44
|
+
* E. Reingold, Software--Practice & Experience, November 1991.
|
45
|
+
*/
|
46
|
+
pv.Layout.Force = function() {
|
47
|
+
pv.Layout.Network.call(this);
|
48
|
+
|
49
|
+
/* Force-directed graphs can be messy, so reduce the link width. */
|
50
|
+
this.link.lineWidth(function(d, p) { return Math.sqrt(p.linkValue) * 1.5; });
|
51
|
+
this.label.textAlign("center");
|
52
|
+
};
|
53
|
+
|
54
|
+
pv.Layout.Force.prototype = pv.extend(pv.Layout.Network)
|
55
|
+
.property("bound", Boolean)
|
56
|
+
.property("iterations", Number)
|
57
|
+
.property("dragConstant", Number)
|
58
|
+
.property("chargeConstant", Number)
|
59
|
+
.property("chargeMinDistance", Number)
|
60
|
+
.property("chargeMaxDistance", Number)
|
61
|
+
.property("chargeTheta", Number)
|
62
|
+
.property("springConstant", Number)
|
63
|
+
.property("springDamping", Number)
|
64
|
+
.property("springLength", Number);
|
65
|
+
|
66
|
+
/**
|
67
|
+
* The bound parameter; true if nodes should be constrained within the layout
|
68
|
+
* panel. Bounding is disabled by default. Currently the layout does not observe
|
69
|
+
* the radius of the nodes; strictly speaking, only the center of the node is
|
70
|
+
* constrained to be within the panel, with an additional 6-pixel offset for
|
71
|
+
* padding. A future enhancement could extend the bound constraint to observe
|
72
|
+
* the node's radius, which would also support bounding for variable-size nodes.
|
73
|
+
*
|
74
|
+
* <p>Note that if this layout is used in conjunction with pan & zoom
|
75
|
+
* behaviors, those behaviors should have their bound parameter set to the same
|
76
|
+
* value.
|
77
|
+
*
|
78
|
+
* @type boolean
|
79
|
+
* @name pv.Layout.Force.prototype.bound
|
80
|
+
*/
|
81
|
+
|
82
|
+
/**
|
83
|
+
* The number of simulation iterations to run, or null if this layout is
|
84
|
+
* interactive. Force-directed layouts are interactive by default, using a
|
85
|
+
* <tt>setInterval</tt> to advance the physics simulation and re-render
|
86
|
+
* automatically.
|
87
|
+
*
|
88
|
+
* @type number
|
89
|
+
* @name pv.Layout.Force.prototype.iterations
|
90
|
+
*/
|
91
|
+
|
92
|
+
/**
|
93
|
+
* The drag constant, in the range [0,1]. A value of 0 means no drag (a
|
94
|
+
* perfectly frictionless environment), while a value of 1 means friction
|
95
|
+
* immediately cancels all momentum. The default value is 0.1, which provides a
|
96
|
+
* minimum amount of drag that helps stabilize bouncy springs; lower values may
|
97
|
+
* result in excessive bounciness, while higher values cause the simulation to
|
98
|
+
* take longer to converge.
|
99
|
+
*
|
100
|
+
* @type number
|
101
|
+
* @name pv.Layout.Force.prototype.dragConstant
|
102
|
+
* @see pv.Force.drag#constant
|
103
|
+
*/
|
104
|
+
|
105
|
+
/**
|
106
|
+
* The charge constant, which should be a negative number. The default value is
|
107
|
+
* -40; more negative values will result in a stronger repulsive force, which
|
108
|
+
* may lead to faster convergence at the risk of instability. Too strong
|
109
|
+
* repulsive charge forces can cause comparatively weak springs to be stretched
|
110
|
+
* well beyond their rest length, emphasizing global structure over local
|
111
|
+
* structure. A nonnegative value will break the Fruchterman-Reingold algorithm,
|
112
|
+
* and is for entertainment purposes only.
|
113
|
+
*
|
114
|
+
* @type number
|
115
|
+
* @name pv.Layout.Force.prototype.chargeConstant
|
116
|
+
* @see pv.Force.charge#constant
|
117
|
+
*/
|
118
|
+
|
119
|
+
/**
|
120
|
+
* The minimum distance at which charge forces are applied. The default minimum
|
121
|
+
* distance of 2 avoids applying forces that are two strong; because the physics
|
122
|
+
* simulation is run at discrete time intervals, it is possible for two same-
|
123
|
+
* charged particles to become very close or even a singularity! Since the
|
124
|
+
* charge force is inversely proportional to the square of the distance, very
|
125
|
+
* small distances can break the simulation.
|
126
|
+
*
|
127
|
+
* <p>In rare cases, two particles can become stuck on top of each other, as a
|
128
|
+
* minimum distance threshold will prevent the charge force from repelling them.
|
129
|
+
* However, this occurs very rarely because other forces and momentum typically
|
130
|
+
* cause the particles to become separated again, at which point the repulsive
|
131
|
+
* charge force kicks in.
|
132
|
+
*
|
133
|
+
* @type number
|
134
|
+
* @name pv.Layout.Force.prototype.chargeMinDistance
|
135
|
+
* @see pv.Force.charge#domain
|
136
|
+
*/
|
137
|
+
|
138
|
+
/**
|
139
|
+
* The maximum distance at which charge forces are applied. This improves
|
140
|
+
* performance by ignoring weak charge forces at great distances. Note that this
|
141
|
+
* parameter is partly redundant, as the Barnes-Hut algorithm for n-body forces
|
142
|
+
* already improves performance for far-away particles through approximation.
|
143
|
+
*
|
144
|
+
* @type number
|
145
|
+
* @name pv.Layout.Force.prototype.chargeMaxDistance
|
146
|
+
* @see pv.Force.charge#domain
|
147
|
+
*/
|
148
|
+
|
149
|
+
/**
|
150
|
+
* The Barnes-Hut approximation factor. The Barnes-Hut approximation criterion
|
151
|
+
* is the ratio of the size of the quadtree node to the distance from the point
|
152
|
+
* to the node's center of mass is beneath some threshold. The default value is
|
153
|
+
* 0.9.
|
154
|
+
*
|
155
|
+
* @type number
|
156
|
+
* @name pv.Layout.Force.prototype.chargeTheta
|
157
|
+
* @see pv.Force.charge#theta
|
158
|
+
*/
|
159
|
+
|
160
|
+
/**
|
161
|
+
* The spring constant, which should be a positive number. The default value is
|
162
|
+
* 0.1; greater values will result in a stronger attractive force, which may
|
163
|
+
* lead to faster convergence at the risk of instability. Too strong spring
|
164
|
+
* forces can cause comparatively weak charge forces to be ignored, emphasizing
|
165
|
+
* local structure over global structure. A nonpositive value will break the
|
166
|
+
* Fruchterman-Reingold algorithm, and is for entertainment purposes only.
|
167
|
+
*
|
168
|
+
* <p>The spring tension is automatically normalized using the inverse square
|
169
|
+
* root of the maximum link degree of attached nodes.
|
170
|
+
*
|
171
|
+
* @type number
|
172
|
+
* @name pv.Layout.Force.prototype.springConstant
|
173
|
+
* @see pv.Force.spring#constant
|
174
|
+
*/
|
175
|
+
|
176
|
+
/**
|
177
|
+
* The spring damping factor, in the range [0,1]. Damping functions identically
|
178
|
+
* to drag forces, damping spring bounciness by applying a force in the opposite
|
179
|
+
* direction of attached nodes' velocities. The default value is 0.3.
|
180
|
+
*
|
181
|
+
* <p>The spring damping is automatically normalized using the inverse square
|
182
|
+
* root of the maximum link degree of attached nodes.
|
183
|
+
*
|
184
|
+
* @type number
|
185
|
+
* @name pv.Layout.Force.prototype.springDamping
|
186
|
+
* @see pv.Force.spring#damping
|
187
|
+
*/
|
188
|
+
|
189
|
+
/**
|
190
|
+
* The spring rest length. The default value is 20 pixels. Larger values may be
|
191
|
+
* appropriate if the layout panel is larger, or if the nodes are rendered
|
192
|
+
* larger than the default dot size of 20.
|
193
|
+
*
|
194
|
+
* @type number
|
195
|
+
* @name pv.Layout.Force.prototype.springLength
|
196
|
+
* @see pv.Force.spring#length
|
197
|
+
*/
|
198
|
+
|
199
|
+
/**
|
200
|
+
* Default properties for force-directed layouts. The default drag constant is
|
201
|
+
* 0.1, the default charge constant is -40 (with a domain of [2, 500] and theta
|
202
|
+
* of 0.9), and the default spring constant is 0.1 (with a damping of 0.3 and a
|
203
|
+
* rest length of 20).
|
204
|
+
*
|
205
|
+
* @type pv.Layout.Force
|
206
|
+
*/
|
207
|
+
pv.Layout.Force.prototype.defaults = new pv.Layout.Force()
|
208
|
+
.extend(pv.Layout.Network.prototype.defaults)
|
209
|
+
.dragConstant(.1)
|
210
|
+
.chargeConstant(-40)
|
211
|
+
.chargeMinDistance(2)
|
212
|
+
.chargeMaxDistance(500)
|
213
|
+
.chargeTheta(.9)
|
214
|
+
.springConstant(.1)
|
215
|
+
.springDamping(.3)
|
216
|
+
.springLength(20);
|
217
|
+
|
218
|
+
/** @private Initialize the physics simulation. */
|
219
|
+
pv.Layout.Force.prototype.buildImplied = function(s) {
|
220
|
+
|
221
|
+
/* Any cached interactive layouts need to be rebound for the timer. */
|
222
|
+
if (pv.Layout.Network.prototype.buildImplied.call(this, s)) {
|
223
|
+
var f = s.$force;
|
224
|
+
if (f) {
|
225
|
+
f.next = this.binds.$force;
|
226
|
+
this.binds.$force = f;
|
227
|
+
}
|
228
|
+
return;
|
229
|
+
}
|
230
|
+
|
231
|
+
var that = this,
|
232
|
+
nodes = s.nodes,
|
233
|
+
links = s.links,
|
234
|
+
k = s.iterations,
|
235
|
+
w = s.width,
|
236
|
+
h = s.height;
|
237
|
+
|
238
|
+
/* Initialize positions randomly near the center. */
|
239
|
+
for (var i = 0, n; i < nodes.length; i++) {
|
240
|
+
n = nodes[i];
|
241
|
+
if (isNaN(n.x)) n.x = w / 2 + 40 * Math.random() - 20;
|
242
|
+
if (isNaN(n.y)) n.y = h / 2 + 40 * Math.random() - 20;
|
243
|
+
}
|
244
|
+
|
245
|
+
/* Initialize the simulation. */
|
246
|
+
var sim = pv.simulation(nodes);
|
247
|
+
|
248
|
+
/* Drag force. */
|
249
|
+
sim.force(pv.Force.drag(s.dragConstant));
|
250
|
+
|
251
|
+
/* Charge (repelling) force. */
|
252
|
+
sim.force(pv.Force.charge(s.chargeConstant)
|
253
|
+
.domain(s.chargeMinDistance, s.chargeMaxDistance)
|
254
|
+
.theta(s.chargeTheta));
|
255
|
+
|
256
|
+
/* Spring (attracting) force. */
|
257
|
+
sim.force(pv.Force.spring(s.springConstant)
|
258
|
+
.damping(s.springDamping)
|
259
|
+
.length(s.springLength)
|
260
|
+
.links(links));
|
261
|
+
|
262
|
+
/* Position constraint (for interactive dragging). */
|
263
|
+
sim.constraint(pv.Constraint.position());
|
264
|
+
|
265
|
+
/* Optionally add bound constraint. TODO: better padding. */
|
266
|
+
if (s.bound) {
|
267
|
+
sim.constraint(pv.Constraint.bound().x(6, w - 6).y(6, h - 6));
|
268
|
+
}
|
269
|
+
|
270
|
+
/** @private Returns the speed of the given node, to determine cooling. */
|
271
|
+
function speed(n) {
|
272
|
+
return n.fix ? 1 : n.vx * n.vx + n.vy * n.vy;
|
273
|
+
}
|
274
|
+
|
275
|
+
/*
|
276
|
+
* If the iterations property is null (the default), the layout is
|
277
|
+
* interactive. The simulation is run until the fastest particle drops below
|
278
|
+
* an arbitrary minimum speed. Although the timer keeps firing, this speed
|
279
|
+
* calculation is fast so there is minimal CPU overhead. Note: if a particle
|
280
|
+
* is fixed for interactivity, treat this as a high speed and resume
|
281
|
+
* simulation.
|
282
|
+
*/
|
283
|
+
if (k == null) {
|
284
|
+
sim.step(); // compute initial previous velocities
|
285
|
+
sim.step(); // compute initial velocities
|
286
|
+
|
287
|
+
/* Add the simulation state to the bound list. */
|
288
|
+
var force = s.$force = this.binds.$force = {
|
289
|
+
next: this.binds.$force,
|
290
|
+
nodes: nodes,
|
291
|
+
min: 1e-4 * (links.length + 1),
|
292
|
+
sim: sim
|
293
|
+
};
|
294
|
+
|
295
|
+
/* Start the timer, if not already started. */
|
296
|
+
if (!this.$timer) this.$timer = setInterval(function() {
|
297
|
+
var render = false;
|
298
|
+
for (var f = that.binds.$force; f; f = f.next) {
|
299
|
+
if (pv.max(f.nodes, speed) > f.min) {
|
300
|
+
f.sim.step();
|
301
|
+
render = true;
|
302
|
+
}
|
303
|
+
}
|
304
|
+
if (render) that.render();
|
305
|
+
}, 42);
|
306
|
+
} else for (var i = 0; i < k; i++) {
|
307
|
+
sim.step();
|
308
|
+
}
|
309
|
+
};
|