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,157 @@
|
|
1
|
+
/**
|
2
|
+
* Returns a new point behavior to be registered on mousemove events.
|
3
|
+
*
|
4
|
+
* @class Implements interactive fuzzy pointing, identifying marks that are in
|
5
|
+
* close proximity to the mouse cursor. This behavior is an alternative to the
|
6
|
+
* native mouseover and mouseout events, improving usability. Rather than
|
7
|
+
* requiring the user to mouseover a mark exactly, the mouse simply needs to
|
8
|
+
* move near the given mark and a "point" event is triggered. In addition, if
|
9
|
+
* multiple marks overlap, the point behavior can be used to identify the mark
|
10
|
+
* instance closest to the cursor, as opposed to the one that is rendered on
|
11
|
+
* top.
|
12
|
+
*
|
13
|
+
* <p>The point behavior can also identify the closest mark instance for marks
|
14
|
+
* that produce a continuous graphic primitive. The point behavior can thus be
|
15
|
+
* used to provide details-on-demand for both discrete marks (such as dots and
|
16
|
+
* bars), as well as continuous marks (such as lines and areas).
|
17
|
+
*
|
18
|
+
* <p>This behavior is implemented by finding the closest mark instance to the
|
19
|
+
* mouse cursor on every mousemove event. If this closest mark is within the
|
20
|
+
* given radius threshold, which defaults to 30 pixels, a "point" psuedo-event
|
21
|
+
* is dispatched to the given mark instance. If any mark were previously
|
22
|
+
* pointed, it would receive a corresponding "unpoint" event. These two
|
23
|
+
* psuedo-event types correspond to the native "mouseover" and "mouseout"
|
24
|
+
* events, respectively. To increase the radius at which the point behavior can
|
25
|
+
* be applied, specify an appropriate threshold to the constructor, up to
|
26
|
+
* <tt>Infinity</tt>.
|
27
|
+
*
|
28
|
+
* <p>By default, the standard Cartesian distance is computed. However, with
|
29
|
+
* some visualizations it is desirable to consider only a single dimension, such
|
30
|
+
* as the <i>x</i>-dimension for an independent variable. In this case, the
|
31
|
+
* collapse parameter can be set to collapse the <i>y</i> dimension:
|
32
|
+
*
|
33
|
+
* <pre> .event("mousemove", pv.Behavior.point(Infinity).collapse("y"))</pre>
|
34
|
+
*
|
35
|
+
* <p>This behavior only listens to mousemove events on the assigned panel,
|
36
|
+
* which is typically the root panel. The behavior will search recursively for
|
37
|
+
* descendant marks to point. If the mouse leaves the assigned panel, the
|
38
|
+
* behavior no longer receives mousemove events; an unpoint psuedo-event is
|
39
|
+
* automatically dispatched to unpoint any pointed mark. Marks may be re-pointed
|
40
|
+
* when the mouse reenters the panel.
|
41
|
+
*
|
42
|
+
* <p>Panels have transparent fill styles by default; this means that panels may
|
43
|
+
* not receive the initial mousemove event to start pointing. To fix this
|
44
|
+
* problem, either given the panel a visible fill style (such as "white"), or
|
45
|
+
* set the <tt>events</tt> property to "all" such that the panel receives events
|
46
|
+
* despite its transparent fill.
|
47
|
+
*
|
48
|
+
* <p>Note: this behavior does not currently wedge marks.
|
49
|
+
*
|
50
|
+
* @extends pv.Behavior
|
51
|
+
*
|
52
|
+
* @param {number} [r] the fuzzy radius threshold in pixels
|
53
|
+
* @see <a href="http://www.tovigrossman.com/papers/chi2005bubblecursor.pdf"
|
54
|
+
* >"The Bubble Cursor: Enhancing Target Acquisition by Dynamic Resizing of the
|
55
|
+
* Cursor's Activation Area"</a> by T. Grossman & R. Balakrishnan, CHI 2005.
|
56
|
+
*/
|
57
|
+
pv.Behavior.point = function(r) {
|
58
|
+
var unpoint, // the current pointer target
|
59
|
+
collapse = null, // dimensions to collapse
|
60
|
+
kx = 1, // x-dimension cost scale
|
61
|
+
ky = 1, // y-dimension cost scale
|
62
|
+
r2 = arguments.length ? r * r : 900; // fuzzy radius
|
63
|
+
|
64
|
+
/** @private Search for the mark closest to the mouse. */
|
65
|
+
function search(scene, index) {
|
66
|
+
var s = scene[index],
|
67
|
+
point = {cost: Infinity};
|
68
|
+
for (var i = 0, n = s.visible && s.children.length; i < n; i++) {
|
69
|
+
var child = s.children[i], mark = child.mark, p;
|
70
|
+
if (mark.type == "panel") {
|
71
|
+
mark.scene = child;
|
72
|
+
for (var j = 0, m = child.length; j < m; j++) {
|
73
|
+
mark.index = j;
|
74
|
+
p = search(child, j);
|
75
|
+
if (p.cost < point.cost) point = p;
|
76
|
+
}
|
77
|
+
delete mark.scene;
|
78
|
+
delete mark.index;
|
79
|
+
} else if (mark.$handlers.point) {
|
80
|
+
var v = mark.mouse();
|
81
|
+
for (var j = 0, m = child.length; j < m; j++) {
|
82
|
+
var c = child[j],
|
83
|
+
dx = v.x - c.left - (c.width || 0) / 2,
|
84
|
+
dy = v.y - c.top - (c.height || 0) / 2,
|
85
|
+
dd = kx * dx * dx + ky * dy * dy;
|
86
|
+
if (dd < point.cost) {
|
87
|
+
point.distance = dx * dx + dy * dy;
|
88
|
+
point.cost = dd;
|
89
|
+
point.scene = child;
|
90
|
+
point.index = j;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
return point;
|
96
|
+
}
|
97
|
+
|
98
|
+
/** @private */
|
99
|
+
function mousemove() {
|
100
|
+
/* If the closest mark is far away, clear the current target. */
|
101
|
+
var point = search(this.scene, this.index);
|
102
|
+
if ((point.cost == Infinity) || (point.distance > r2)) point = null;
|
103
|
+
|
104
|
+
/* Unpoint the old target, if it's not the new target. */
|
105
|
+
if (unpoint) {
|
106
|
+
if (point
|
107
|
+
&& (unpoint.scene == point.scene)
|
108
|
+
&& (unpoint.index == point.index)) return;
|
109
|
+
pv.Mark.dispatch("unpoint", unpoint.scene, unpoint.index);
|
110
|
+
}
|
111
|
+
|
112
|
+
/* Point the new target, if there is one. */
|
113
|
+
if (unpoint = point) {
|
114
|
+
pv.Mark.dispatch("point", point.scene, point.index);
|
115
|
+
|
116
|
+
/* Unpoint when the mouse leaves the root panel. */
|
117
|
+
pv.listen(this.root.canvas(), "mouseout", mouseout);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
/** @private */
|
122
|
+
function mouseout(e) {
|
123
|
+
if (unpoint && !pv.ancestor(this, e.relatedTarget)) {
|
124
|
+
pv.Mark.dispatch("unpoint", unpoint.scene, unpoint.index);
|
125
|
+
unpoint = null;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Sets or gets the collapse parameter. By default, the standard Cartesian
|
131
|
+
* distance is computed. However, with some visualizations it is desirable to
|
132
|
+
* consider only a single dimension, such as the <i>x</i>-dimension for an
|
133
|
+
* independent variable. In this case, the collapse parameter can be set to
|
134
|
+
* collapse the <i>y</i> dimension:
|
135
|
+
*
|
136
|
+
* <pre> .event("mousemove", pv.Behavior.point(Infinity).collapse("y"))</pre>
|
137
|
+
*
|
138
|
+
* @function
|
139
|
+
* @returns {pv.Behavior.point} this, or the current collapse parameter.
|
140
|
+
* @name pv.Behavior.point.prototype.collapse
|
141
|
+
* @param {string} [x] the new collapse parameter
|
142
|
+
*/
|
143
|
+
mousemove.collapse = function(x) {
|
144
|
+
if (arguments.length) {
|
145
|
+
collapse = String(x);
|
146
|
+
switch (collapse) {
|
147
|
+
case "y": kx = 1; ky = 0; break;
|
148
|
+
case "x": kx = 0; ky = 1; break;
|
149
|
+
default: kx = 1; ky = 1; break;
|
150
|
+
}
|
151
|
+
return mousemove;
|
152
|
+
}
|
153
|
+
return collapse;
|
154
|
+
};
|
155
|
+
|
156
|
+
return mousemove;
|
157
|
+
};
|
@@ -0,0 +1,104 @@
|
|
1
|
+
/**
|
2
|
+
* Returns a new resize behavior to be registered on mousedown events.
|
3
|
+
*
|
4
|
+
* @class Implements interactive resizing of a selection starting with mousedown
|
5
|
+
* events. Register this behavior on selection handles that should be resizeable
|
6
|
+
* by the user, such for brushing and linking. This behavior can be used in
|
7
|
+
* tandom with {@link pv.Behavior.select} and {@link pv.Behavior.drag} to allow
|
8
|
+
* the selected region to be selected and dragged interactively.
|
9
|
+
*
|
10
|
+
* <p>After the initial mousedown event is triggered, this behavior listens for
|
11
|
+
* mousemove and mouseup events on the window. This allows resizing to continue
|
12
|
+
* even if the mouse temporarily leaves the assigned panel, or even the root
|
13
|
+
* panel.
|
14
|
+
*
|
15
|
+
* <p>This behavior requires that the data associated with the mark being
|
16
|
+
* resized have <tt>x</tt>, <tt>y</tt>, <tt>dx</tt> and <tt>dy</tt> attributes
|
17
|
+
* that correspond to the mark's location and dimensions in pixels. The mark's
|
18
|
+
* positional properties are not set directly by this behavior; instead, the
|
19
|
+
* positional properties should be defined as:
|
20
|
+
*
|
21
|
+
* <pre> .left(function(d) d.x)
|
22
|
+
* .top(function(d) d.y)
|
23
|
+
* .width(function(d) d.dx)
|
24
|
+
* .height(function(d) d.dy)</pre>
|
25
|
+
*
|
26
|
+
* Thus, the behavior does not resize the mark directly, but instead updates the
|
27
|
+
* size by updating the assigned panel's underlying data. Note that if the
|
28
|
+
* positional properties are defined with bottom and right (rather than top and
|
29
|
+
* left), the resize behavior will be inverted, which will confuse users!
|
30
|
+
*
|
31
|
+
* <p>The resize behavior is bounded by the assigned mark's enclosing panel; the
|
32
|
+
* positional attributes are clamped such that the selection does not extend
|
33
|
+
* outside the panel's bounds.
|
34
|
+
*
|
35
|
+
* <p>The mark being resized is automatically re-rendered for each mouse event
|
36
|
+
* as part of the resize operation. This behavior may be enhanced in the future
|
37
|
+
* to allow more flexible configuration. In some cases, such as with parallel
|
38
|
+
* coordinates, resizing the selection may cause related marks to change, in
|
39
|
+
* which case additional marks may also need to be rendered. This can be
|
40
|
+
* accomplished by listening for the select psuedo-events:<ul>
|
41
|
+
*
|
42
|
+
* <li>resizestart (on mousedown)
|
43
|
+
* <li>resize (on mousemove)
|
44
|
+
* <li>resizeend (on mouseup)
|
45
|
+
*
|
46
|
+
* </ul>For example, to render the parent panel while resizing, thus
|
47
|
+
* re-rendering all sibling marks:
|
48
|
+
*
|
49
|
+
* <pre> .event("mousedown", pv.Behavior.resize("left"))
|
50
|
+
* .event("resize", function() this.parent)</pre>
|
51
|
+
*
|
52
|
+
* This behavior may be enhanced in the future to allow more flexible
|
53
|
+
* configuration of the selection behavior.
|
54
|
+
*
|
55
|
+
* @extends pv.Behavior
|
56
|
+
* @see pv.Behavior.select
|
57
|
+
* @see pv.Behavior.drag
|
58
|
+
*/
|
59
|
+
pv.Behavior.resize = function(side) {
|
60
|
+
var scene, // scene context
|
61
|
+
index, // scene context
|
62
|
+
r, // region being selected
|
63
|
+
m1; // initial mouse position
|
64
|
+
|
65
|
+
/** @private */
|
66
|
+
function mousedown(d) {
|
67
|
+
index = this.index;
|
68
|
+
scene = this.scene;
|
69
|
+
m1 = this.mouse();
|
70
|
+
r = d;
|
71
|
+
switch (side) {
|
72
|
+
case "left": m1.x = r.x + r.dx; break;
|
73
|
+
case "right": m1.x = r.x; break;
|
74
|
+
case "top": m1.y = r.y + r.dy; break;
|
75
|
+
case "bottom": m1.y = r.y; break;
|
76
|
+
}
|
77
|
+
pv.Mark.dispatch("resizestart", scene, index);
|
78
|
+
}
|
79
|
+
|
80
|
+
/** @private */
|
81
|
+
function mousemove() {
|
82
|
+
if (!scene) return;
|
83
|
+
scene.mark.context(scene, index, function() {
|
84
|
+
var m2 = this.mouse();
|
85
|
+
r.x = Math.max(0, Math.min(m1.x, m2.x));
|
86
|
+
r.y = Math.max(0, Math.min(m1.y, m2.y));
|
87
|
+
r.dx = Math.min(this.parent.width(), Math.max(m2.x, m1.x)) - r.x;
|
88
|
+
r.dy = Math.min(this.parent.height(), Math.max(m2.y, m1.y)) - r.y;
|
89
|
+
this.render();
|
90
|
+
});
|
91
|
+
pv.Mark.dispatch("resize", scene, index);
|
92
|
+
}
|
93
|
+
|
94
|
+
/** @private */
|
95
|
+
function mouseup() {
|
96
|
+
if (!scene) return;
|
97
|
+
pv.Mark.dispatch("resizeend", scene, index);
|
98
|
+
scene = null;
|
99
|
+
}
|
100
|
+
|
101
|
+
pv.listen(window, "mousemove", mousemove);
|
102
|
+
pv.listen(window, "mouseup", mouseup);
|
103
|
+
return mousedown;
|
104
|
+
};
|
@@ -0,0 +1,100 @@
|
|
1
|
+
/**
|
2
|
+
* Returns a new select behavior to be registered on mousedown events.
|
3
|
+
*
|
4
|
+
* @class Implements interactive selecting starting with mousedown events.
|
5
|
+
* Register this behavior on panels that should be selectable by the user, such
|
6
|
+
* for brushing and linking. This behavior can be used in tandom with
|
7
|
+
* {@link pv.Behavior.drag} to allow the selected region to be dragged
|
8
|
+
* interactively.
|
9
|
+
*
|
10
|
+
* <p>After the initial mousedown event is triggered, this behavior listens for
|
11
|
+
* mousemove and mouseup events on the window. This allows selecting to continue
|
12
|
+
* even if the mouse temporarily leaves the assigned panel, or even the root
|
13
|
+
* panel.
|
14
|
+
*
|
15
|
+
* <p>This behavior requires that the data associated with the mark being
|
16
|
+
* dragged have <tt>x</tt>, <tt>y</tt>, <tt>dx</tt> and <tt>dy</tt> attributes
|
17
|
+
* that correspond to the mark's location and dimensions in pixels. The mark's
|
18
|
+
* positional properties are not set directly by this behavior; instead, the
|
19
|
+
* positional properties should be defined as:
|
20
|
+
*
|
21
|
+
* <pre> .left(function(d) d.x)
|
22
|
+
* .top(function(d) d.y)
|
23
|
+
* .width(function(d) d.dx)
|
24
|
+
* .height(function(d) d.dy)</pre>
|
25
|
+
*
|
26
|
+
* Thus, the behavior does not resize the mark directly, but instead updates the
|
27
|
+
* selection by updating the assigned panel's underlying data. Note that if the
|
28
|
+
* positional properties are defined with bottom and right (rather than top and
|
29
|
+
* left), the drag behavior will be inverted, which will confuse users!
|
30
|
+
*
|
31
|
+
* <p>The select behavior is bounded by the assigned panel; the positional
|
32
|
+
* attributes are clamped such that the selection does not extend outside the
|
33
|
+
* panel's bounds.
|
34
|
+
*
|
35
|
+
* <p>The panel being selected is automatically re-rendered for each mouse event
|
36
|
+
* as part of the drag operation. This behavior may be enhanced in the future to
|
37
|
+
* allow more flexible configuration of select behavior. In some cases, such as
|
38
|
+
* with parallel coordinates, making a selection may cause related marks to
|
39
|
+
* change, in which case additional marks may also need to be rendered. This can
|
40
|
+
* be accomplished by listening for the select psuedo-events:<ul>
|
41
|
+
*
|
42
|
+
* <li>selectstart (on mousedown)
|
43
|
+
* <li>select (on mousemove)
|
44
|
+
* <li>selectend (on mouseup)
|
45
|
+
*
|
46
|
+
* </ul>For example, to render the parent panel while selecting, thus
|
47
|
+
* re-rendering all sibling marks:
|
48
|
+
*
|
49
|
+
* <pre> .event("mousedown", pv.Behavior.drag())
|
50
|
+
* .event("select", function() this.parent)</pre>
|
51
|
+
*
|
52
|
+
* This behavior may be enhanced in the future to allow more flexible
|
53
|
+
* configuration of the selection behavior.
|
54
|
+
*
|
55
|
+
* @extends pv.Behavior
|
56
|
+
* @see pv.Behavior.drag
|
57
|
+
*/
|
58
|
+
pv.Behavior.select = function() {
|
59
|
+
var scene, // scene context
|
60
|
+
index, // scene context
|
61
|
+
r, // region being selected
|
62
|
+
m1; // initial mouse position
|
63
|
+
|
64
|
+
/** @private */
|
65
|
+
function mousedown(d) {
|
66
|
+
index = this.index;
|
67
|
+
scene = this.scene;
|
68
|
+
m1 = this.mouse();
|
69
|
+
r = d;
|
70
|
+
r.x = m1.x;
|
71
|
+
r.y = m1.y;
|
72
|
+
r.dx = r.dy = 0;
|
73
|
+
pv.Mark.dispatch("selectstart", scene, index);
|
74
|
+
}
|
75
|
+
|
76
|
+
/** @private */
|
77
|
+
function mousemove() {
|
78
|
+
if (!scene) return;
|
79
|
+
scene.mark.context(scene, index, function() {
|
80
|
+
var m2 = this.mouse();
|
81
|
+
r.x = Math.max(0, Math.min(m1.x, m2.x));
|
82
|
+
r.y = Math.max(0, Math.min(m1.y, m2.y));
|
83
|
+
r.dx = Math.min(this.width(), Math.max(m2.x, m1.x)) - r.x;
|
84
|
+
r.dy = Math.min(this.height(), Math.max(m2.y, m1.y)) - r.y;
|
85
|
+
this.render();
|
86
|
+
});
|
87
|
+
pv.Mark.dispatch("select", scene, index);
|
88
|
+
}
|
89
|
+
|
90
|
+
/** @private */
|
91
|
+
function mouseup() {
|
92
|
+
if (!scene) return;
|
93
|
+
pv.Mark.dispatch("selectend", scene, index);
|
94
|
+
scene = null;
|
95
|
+
}
|
96
|
+
|
97
|
+
pv.listen(window, "mousemove", mousemove);
|
98
|
+
pv.listen(window, "mouseup", mouseup);
|
99
|
+
return mousedown;
|
100
|
+
};
|
@@ -0,0 +1,85 @@
|
|
1
|
+
/**
|
2
|
+
* Returns a new zoom behavior to be registered on mousewheel events.
|
3
|
+
*
|
4
|
+
* @class Implements interactive zooming using mousewheel events. Register this
|
5
|
+
* behavior on panels to allow zooming. This behavior can be used in tandem with
|
6
|
+
* {@link pv.Behavior.pan} to allow both panning and zooming:
|
7
|
+
*
|
8
|
+
* <pre> .event("mousedown", pv.Behavior.pan())
|
9
|
+
* .event("mousewheel", pv.Behavior.zoom())</pre>
|
10
|
+
*
|
11
|
+
* The zoom behavior currently supports only mousewheel events; support for
|
12
|
+
* keyboard shortcuts and gesture events to improve accessibility may be added
|
13
|
+
* in the future.
|
14
|
+
*
|
15
|
+
* <p>The implementation of this behavior relies on the panel's
|
16
|
+
* <tt>transform</tt> property, which specifies a matrix transformation that is
|
17
|
+
* applied to child marks. Note that the transform property only affects the
|
18
|
+
* panel's children, but not the panel itself; therefore the panel's fill and
|
19
|
+
* stroke will not change when the contents are zoomed. The built-in support for
|
20
|
+
* transforms only supports uniform scaling and translates, which is sufficient
|
21
|
+
* for panning and zooming. Note that this is not a strict geometric
|
22
|
+
* transformation, as the <tt>lineWidth</tt> property is scale-aware: strokes
|
23
|
+
* are drawn at constant size independent of scale.
|
24
|
+
*
|
25
|
+
* <p>Panels have transparent fill styles by default; this means that panels may
|
26
|
+
* not receive mousewheel events to zoom. To fix this problem, either given the
|
27
|
+
* panel a visible fill style (such as "white"), or set the <tt>events</tt>
|
28
|
+
* property to "all" such that the panel receives events despite its transparent
|
29
|
+
* fill.
|
30
|
+
*
|
31
|
+
* <p>The zoom behavior has optional support for bounding. If enabled, the user
|
32
|
+
* will not be able to zoom out farther than the initial bounds. This feature is
|
33
|
+
* designed to work in conjunction with the pan behavior.
|
34
|
+
*
|
35
|
+
* @extends pv.Behavior
|
36
|
+
* @see pv.Panel#transform
|
37
|
+
* @see pv.Mark#scale
|
38
|
+
* @param {number} speed
|
39
|
+
*/
|
40
|
+
pv.Behavior.zoom = function(speed) {
|
41
|
+
var bound; // whether to bound to the panel
|
42
|
+
|
43
|
+
if (!arguments.length) speed = 1 / 48;
|
44
|
+
|
45
|
+
/** @private */
|
46
|
+
function mousewheel() {
|
47
|
+
var v = this.mouse(),
|
48
|
+
k = pv.event.wheel * speed,
|
49
|
+
m = this.transform().translate(v.x, v.y)
|
50
|
+
.scale((k < 0) ? (1e3 / (1e3 - k)) : ((1e3 + k) / 1e3))
|
51
|
+
.translate(-v.x, -v.y);
|
52
|
+
if (bound) {
|
53
|
+
m.k = Math.max(1, m.k);
|
54
|
+
m.x = Math.max((1 - m.k) * this.width(), Math.min(0, m.x));
|
55
|
+
m.y = Math.max((1 - m.k) * this.height(), Math.min(0, m.y));
|
56
|
+
}
|
57
|
+
this.transform(m).render();
|
58
|
+
pv.Mark.dispatch("zoom", this.scene, this.index);
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Sets or gets the bound parameter. If bounding is enabled, the user will not
|
63
|
+
* be able to zoom out farther than the initial panel bounds. Bounding is not
|
64
|
+
* enabled by default. If this behavior is used in tandem with the pan
|
65
|
+
* behavior, both should use the same bound parameter.
|
66
|
+
*
|
67
|
+
* <p>Note: enabling bounding after zooming has already occurred will not
|
68
|
+
* immediately reset the transform. Bounding should be enabled before the zoom
|
69
|
+
* behavior is applied.
|
70
|
+
*
|
71
|
+
* @function
|
72
|
+
* @returns {pv.Behavior.zoom} this, or the current bound parameter.
|
73
|
+
* @name pv.Behavior.zoom.prototype.bound
|
74
|
+
* @param {boolean} [x] the new bound parameter.
|
75
|
+
*/
|
76
|
+
mousewheel.bound = function(x) {
|
77
|
+
if (arguments.length) {
|
78
|
+
bound = Boolean(x);
|
79
|
+
return this;
|
80
|
+
}
|
81
|
+
return Boolean(bound);
|
82
|
+
};
|
83
|
+
|
84
|
+
return mousewheel;
|
85
|
+
};
|