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,440 @@
|
|
1
|
+
/**
|
2
|
+
* Returns a default quantitative, linear, scale for the specified domain. The
|
3
|
+
* arguments to this constructor are optional, and equivalent to calling
|
4
|
+
* {@link #domain}. The default domain and range are [0,1].
|
5
|
+
*
|
6
|
+
* <p>This constructor is typically not used directly; see one of the
|
7
|
+
* quantitative scale implementations instead.
|
8
|
+
*
|
9
|
+
* @class Represents an abstract quantitative scale; a function that performs a
|
10
|
+
* numeric transformation. This class is typically not used directly; see one of
|
11
|
+
* the quantitative scale implementations (linear, log, root, etc.)
|
12
|
+
* instead. <style type="text/css">sub{line-height:0}</style> A quantitative
|
13
|
+
* scale represents a 1-dimensional transformation from a numeric domain of
|
14
|
+
* input data [<i>d<sub>0</sub></i>, <i>d<sub>1</sub></i>] to a numeric range of
|
15
|
+
* pixels [<i>r<sub>0</sub></i>, <i>r<sub>1</sub></i>]. In addition to
|
16
|
+
* readability, scales offer several useful features:
|
17
|
+
*
|
18
|
+
* <p>1. The range can be expressed in colors, rather than pixels. For example:
|
19
|
+
*
|
20
|
+
* <pre> .fillStyle(pv.Scale.linear(0, 100).range("red", "green"))</pre>
|
21
|
+
*
|
22
|
+
* will fill the marks "red" on an input value of 0, "green" on an input value
|
23
|
+
* of 100, and some color in-between for intermediate values.
|
24
|
+
*
|
25
|
+
* <p>2. The domain and range can be subdivided for a non-uniform
|
26
|
+
* transformation. For example, you may want a diverging color scale that is
|
27
|
+
* increasingly red for negative values, and increasingly green for positive
|
28
|
+
* values:
|
29
|
+
*
|
30
|
+
* <pre> .fillStyle(pv.Scale.linear(-1, 0, 1).range("red", "white", "green"))</pre>
|
31
|
+
*
|
32
|
+
* The domain can be specified as a series of <i>n</i> monotonically-increasing
|
33
|
+
* values; the range must also be specified as <i>n</i> values, resulting in
|
34
|
+
* <i>n - 1</i> contiguous linear scales.
|
35
|
+
*
|
36
|
+
* <p>3. Quantitative scales can be inverted for interaction. The
|
37
|
+
* {@link #invert} method takes a value in the output range, and returns the
|
38
|
+
* corresponding value in the input domain. This is frequently used to convert
|
39
|
+
* the mouse location (see {@link pv.Mark#mouse}) to a value in the input
|
40
|
+
* domain. Note that inversion is only supported for numeric ranges, and not
|
41
|
+
* colors.
|
42
|
+
*
|
43
|
+
* <p>4. A scale can be queried for reasonable "tick" values. The {@link #ticks}
|
44
|
+
* method provides a convenient way to get a series of evenly-spaced rounded
|
45
|
+
* values in the input domain. Frequently these are used in conjunction with
|
46
|
+
* {@link pv.Rule} to display tick marks or grid lines.
|
47
|
+
*
|
48
|
+
* <p>5. A scale can be "niced" to extend the domain to suitable rounded
|
49
|
+
* numbers. If the minimum and maximum of the domain are messy because they are
|
50
|
+
* derived from data, you can use {@link #nice} to round these values down and
|
51
|
+
* up to even numbers.
|
52
|
+
*
|
53
|
+
* @param {number...} domain... optional domain values.
|
54
|
+
* @see pv.Scale.linear
|
55
|
+
* @see pv.Scale.log
|
56
|
+
* @see pv.Scale.root
|
57
|
+
* @extends pv.Scale
|
58
|
+
*/
|
59
|
+
pv.Scale.quantitative = function() {
|
60
|
+
var d = [0, 1], // default domain
|
61
|
+
l = [0, 1], // default transformed domain
|
62
|
+
r = [0, 1], // default range
|
63
|
+
i = [pv.identity], // default interpolators
|
64
|
+
type = Number, // default type
|
65
|
+
n = false, // whether the domain is negative
|
66
|
+
f = pv.identity, // default forward transform
|
67
|
+
g = pv.identity, // default inverse transform
|
68
|
+
tickFormat = String; // default tick formatting function
|
69
|
+
|
70
|
+
/** @private */
|
71
|
+
function newDate(x) {
|
72
|
+
return new Date(x);
|
73
|
+
}
|
74
|
+
|
75
|
+
/** @private */
|
76
|
+
function scale(x) {
|
77
|
+
var j = pv.search(d, x);
|
78
|
+
if (j < 0) j = -j - 2;
|
79
|
+
j = Math.max(0, Math.min(i.length - 1, j));
|
80
|
+
return i[j]((f(x) - l[j]) / (l[j + 1] - l[j]));
|
81
|
+
}
|
82
|
+
|
83
|
+
/** @private */
|
84
|
+
scale.transform = function(forward, inverse) {
|
85
|
+
/** @ignore */ f = function(x) { return n ? -forward(-x) : forward(x); };
|
86
|
+
/** @ignore */ g = function(y) { return n ? -inverse(-y) : inverse(y); };
|
87
|
+
l = d.map(f);
|
88
|
+
return this;
|
89
|
+
};
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Sets or gets the input domain. This method can be invoked several ways:
|
93
|
+
*
|
94
|
+
* <p>1. <tt>domain(min, ..., max)</tt>
|
95
|
+
*
|
96
|
+
* <p>Specifying the domain as a series of numbers is the most explicit and
|
97
|
+
* recommended approach. Most commonly, two numbers are specified: the minimum
|
98
|
+
* and maximum value. However, for a diverging scale, or other subdivided
|
99
|
+
* non-uniform scales, multiple values can be specified. Values can be derived
|
100
|
+
* from data using {@link pv.min} and {@link pv.max}. For example:
|
101
|
+
*
|
102
|
+
* <pre> .domain(0, pv.max(array))</pre>
|
103
|
+
*
|
104
|
+
* An alternative method for deriving minimum and maximum values from data
|
105
|
+
* follows.
|
106
|
+
*
|
107
|
+
* <p>2. <tt>domain(array, minf, maxf)</tt>
|
108
|
+
*
|
109
|
+
* <p>When both the minimum and maximum value are derived from data, the
|
110
|
+
* arguments to the <tt>domain</tt> method can be specified as the array of
|
111
|
+
* data, followed by zero, one or two accessor functions. For example, if the
|
112
|
+
* array of data is just an array of numbers:
|
113
|
+
*
|
114
|
+
* <pre> .domain(array)</pre>
|
115
|
+
*
|
116
|
+
* On the other hand, if the array elements are objects representing stock
|
117
|
+
* values per day, and the domain should consider the stock's daily low and
|
118
|
+
* daily high:
|
119
|
+
*
|
120
|
+
* <pre> .domain(array, function(d) d.low, function(d) d.high)</pre>
|
121
|
+
*
|
122
|
+
* The first method of setting the domain is preferred because it is more
|
123
|
+
* explicit; setting the domain using this second method should be used only
|
124
|
+
* if brevity is required.
|
125
|
+
*
|
126
|
+
* <p>3. <tt>domain()</tt>
|
127
|
+
*
|
128
|
+
* <p>Invoking the <tt>domain</tt> method with no arguments returns the
|
129
|
+
* current domain as an array of numbers.
|
130
|
+
*
|
131
|
+
* @function
|
132
|
+
* @name pv.Scale.quantitative.prototype.domain
|
133
|
+
* @param {number...} domain... domain values.
|
134
|
+
* @returns {pv.Scale.quantitative} <tt>this</tt>, or the current domain.
|
135
|
+
*/
|
136
|
+
scale.domain = function(array, min, max) {
|
137
|
+
if (arguments.length) {
|
138
|
+
var o; // the object we use to infer the domain type
|
139
|
+
if (array instanceof Array) {
|
140
|
+
if (arguments.length < 2) min = pv.identity;
|
141
|
+
if (arguments.length < 3) max = min;
|
142
|
+
o = array.length && min(array[0]);
|
143
|
+
d = array.length ? [pv.min(array, min), pv.max(array, max)] : [];
|
144
|
+
} else {
|
145
|
+
o = array;
|
146
|
+
d = Array.prototype.slice.call(arguments).map(Number);
|
147
|
+
}
|
148
|
+
if (!d.length) d = [-Infinity, Infinity];
|
149
|
+
else if (d.length == 1) d = [d[0], d[0]];
|
150
|
+
n = (d[0] || d[d.length - 1]) < 0;
|
151
|
+
l = d.map(f);
|
152
|
+
type = (o instanceof Date) ? newDate : Number;
|
153
|
+
return this;
|
154
|
+
}
|
155
|
+
return d.map(type);
|
156
|
+
};
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Sets or gets the output range. This method can be invoked several ways:
|
160
|
+
*
|
161
|
+
* <p>1. <tt>range(min, ..., max)</tt>
|
162
|
+
*
|
163
|
+
* <p>The range may be specified as a series of numbers or colors. Most
|
164
|
+
* commonly, two numbers are specified: the minimum and maximum pixel values.
|
165
|
+
* For a color scale, values may be specified as {@link pv.Color}s or
|
166
|
+
* equivalent strings. For a diverging scale, or other subdivided non-uniform
|
167
|
+
* scales, multiple values can be specified. For example:
|
168
|
+
*
|
169
|
+
* <pre> .range("red", "white", "green")</pre>
|
170
|
+
*
|
171
|
+
* <p>Currently, only numbers and colors are supported as range values. The
|
172
|
+
* number of range values must exactly match the number of domain values, or
|
173
|
+
* the behavior of the scale is undefined.
|
174
|
+
*
|
175
|
+
* <p>2. <tt>range()</tt>
|
176
|
+
*
|
177
|
+
* <p>Invoking the <tt>range</tt> method with no arguments returns the current
|
178
|
+
* range as an array of numbers or colors.
|
179
|
+
*
|
180
|
+
* @function
|
181
|
+
* @name pv.Scale.quantitative.prototype.range
|
182
|
+
* @param {...} range... range values.
|
183
|
+
* @returns {pv.Scale.quantitative} <tt>this</tt>, or the current range.
|
184
|
+
*/
|
185
|
+
scale.range = function() {
|
186
|
+
if (arguments.length) {
|
187
|
+
r = Array.prototype.slice.call(arguments);
|
188
|
+
if (!r.length) r = [-Infinity, Infinity];
|
189
|
+
else if (r.length == 1) r = [r[0], r[0]];
|
190
|
+
i = [];
|
191
|
+
for (var j = 0; j < r.length - 1; j++) {
|
192
|
+
i.push(pv.Scale.interpolator(r[j], r[j + 1]));
|
193
|
+
}
|
194
|
+
return this;
|
195
|
+
}
|
196
|
+
return r;
|
197
|
+
};
|
198
|
+
|
199
|
+
/**
|
200
|
+
* Inverts the specified value in the output range, returning the
|
201
|
+
* corresponding value in the input domain. This is frequently used to convert
|
202
|
+
* the mouse location (see {@link pv.Mark#mouse}) to a value in the input
|
203
|
+
* domain. Inversion is only supported for numeric ranges, and not colors.
|
204
|
+
*
|
205
|
+
* <p>Note that this method does not do any rounding or bounds checking. If
|
206
|
+
* the input domain is discrete (e.g., an array index), the returned value
|
207
|
+
* should be rounded. If the specified <tt>y</tt> value is outside the range,
|
208
|
+
* the returned value may be equivalently outside the input domain.
|
209
|
+
*
|
210
|
+
* @function
|
211
|
+
* @name pv.Scale.quantitative.prototype.invert
|
212
|
+
* @param {number} y a value in the output range (a pixel location).
|
213
|
+
* @returns {number} a value in the input domain.
|
214
|
+
*/
|
215
|
+
scale.invert = function(y) {
|
216
|
+
var j = pv.search(r, y);
|
217
|
+
if (j < 0) j = -j - 2;
|
218
|
+
j = Math.max(0, Math.min(i.length - 1, j));
|
219
|
+
return type(g(l[j] + (y - r[j]) / (r[j + 1] - r[j]) * (l[j + 1] - l[j])));
|
220
|
+
};
|
221
|
+
|
222
|
+
/**
|
223
|
+
* Returns an array of evenly-spaced, suitably-rounded values in the input
|
224
|
+
* domain. This method attempts to return between 5 and 10 tick values. These
|
225
|
+
* values are frequently used in conjunction with {@link pv.Rule} to display
|
226
|
+
* tick marks or grid lines.
|
227
|
+
*
|
228
|
+
* @function
|
229
|
+
* @name pv.Scale.quantitative.prototype.ticks
|
230
|
+
* @param {number} [m] optional number of desired ticks.
|
231
|
+
* @returns {number[]} an array input domain values to use as ticks.
|
232
|
+
*/
|
233
|
+
scale.ticks = function(m) {
|
234
|
+
var start = d[0],
|
235
|
+
end = d[d.length - 1],
|
236
|
+
reverse = end < start,
|
237
|
+
min = reverse ? end : start,
|
238
|
+
max = reverse ? start : end,
|
239
|
+
span = max - min;
|
240
|
+
|
241
|
+
/* Special case: empty, invalid or infinite span. */
|
242
|
+
if (!span || !isFinite(span)) {
|
243
|
+
if (type == newDate) tickFormat = pv.Format.date("%x");
|
244
|
+
return [type(min)];
|
245
|
+
}
|
246
|
+
|
247
|
+
/* Special case: dates. */
|
248
|
+
if (type == newDate) {
|
249
|
+
/* Floor the date d given the precision p. */
|
250
|
+
function floor(d, p) {
|
251
|
+
switch (p) {
|
252
|
+
case 31536e6: d.setMonth(0);
|
253
|
+
case 2592e6: d.setDate(1);
|
254
|
+
case 6048e5: if (p == 6048e5) d.setDate(d.getDate() - d.getDay());
|
255
|
+
case 864e5: d.setHours(0);
|
256
|
+
case 36e5: d.setMinutes(0);
|
257
|
+
case 6e4: d.setSeconds(0);
|
258
|
+
case 1e3: d.setMilliseconds(0);
|
259
|
+
}
|
260
|
+
}
|
261
|
+
|
262
|
+
var precision, format, increment, step = 1;
|
263
|
+
if (span >= 3 * 31536e6) {
|
264
|
+
precision = 31536e6;
|
265
|
+
format = "%Y";
|
266
|
+
/** @ignore */ increment = function(d) { d.setFullYear(d.getFullYear() + step); };
|
267
|
+
} else if (span >= 3 * 2592e6) {
|
268
|
+
precision = 2592e6;
|
269
|
+
format = "%m/%Y";
|
270
|
+
/** @ignore */ increment = function(d) { d.setMonth(d.getMonth() + step); };
|
271
|
+
} else if (span >= 3 * 6048e5) {
|
272
|
+
precision = 6048e5;
|
273
|
+
format = "%m/%d";
|
274
|
+
/** @ignore */ increment = function(d) { d.setDate(d.getDate() + 7 * step); };
|
275
|
+
} else if (span >= 3 * 864e5) {
|
276
|
+
precision = 864e5;
|
277
|
+
format = "%m/%d";
|
278
|
+
/** @ignore */ increment = function(d) { d.setDate(d.getDate() + step); };
|
279
|
+
} else if (span >= 3 * 36e5) {
|
280
|
+
precision = 36e5;
|
281
|
+
format = "%I:%M %p";
|
282
|
+
/** @ignore */ increment = function(d) { d.setHours(d.getHours() + step); };
|
283
|
+
} else if (span >= 3 * 6e4) {
|
284
|
+
precision = 6e4;
|
285
|
+
format = "%I:%M %p";
|
286
|
+
/** @ignore */ increment = function(d) { d.setMinutes(d.getMinutes() + step); };
|
287
|
+
} else if (span >= 3 * 1e3) {
|
288
|
+
precision = 1e3;
|
289
|
+
format = "%I:%M:%S";
|
290
|
+
/** @ignore */ increment = function(d) { d.setSeconds(d.getSeconds() + step); };
|
291
|
+
} else {
|
292
|
+
precision = 1;
|
293
|
+
format = "%S.%Qs";
|
294
|
+
/** @ignore */ increment = function(d) { d.setTime(d.getTime() + step); };
|
295
|
+
}
|
296
|
+
tickFormat = pv.Format.date(format);
|
297
|
+
|
298
|
+
var date = new Date(min), dates = [];
|
299
|
+
floor(date, precision);
|
300
|
+
|
301
|
+
/* If we'd generate too many ticks, skip some!. */
|
302
|
+
var n = span / precision;
|
303
|
+
if (n > 10) {
|
304
|
+
switch (precision) {
|
305
|
+
case 36e5: {
|
306
|
+
step = (n > 20) ? 6 : 3;
|
307
|
+
date.setHours(Math.floor(date.getHours() / step) * step);
|
308
|
+
break;
|
309
|
+
}
|
310
|
+
case 2592e6: {
|
311
|
+
step = 3; // seasons
|
312
|
+
date.setMonth(Math.floor(date.getMonth() / step) * step);
|
313
|
+
break;
|
314
|
+
}
|
315
|
+
case 6e4: {
|
316
|
+
step = (n > 30) ? 15 : ((n > 15) ? 10 : 5);
|
317
|
+
date.setMinutes(Math.floor(date.getMinutes() / step) * step);
|
318
|
+
break;
|
319
|
+
}
|
320
|
+
case 1e3: {
|
321
|
+
step = (n > 90) ? 15 : ((n > 60) ? 10 : 5);
|
322
|
+
date.setSeconds(Math.floor(date.getSeconds() / step) * step);
|
323
|
+
break;
|
324
|
+
}
|
325
|
+
case 1: {
|
326
|
+
step = (n > 1000) ? 250 : ((n > 200) ? 100 : ((n > 100) ? 50 : ((n > 50) ? 25 : 5)));
|
327
|
+
date.setMilliseconds(Math.floor(date.getMilliseconds() / step) * step);
|
328
|
+
break;
|
329
|
+
}
|
330
|
+
default: {
|
331
|
+
step = pv.logCeil(n / 15, 10);
|
332
|
+
if (n / step < 2) step /= 5;
|
333
|
+
else if (n / step < 5) step /= 2;
|
334
|
+
date.setFullYear(Math.floor(date.getFullYear() / step) * step);
|
335
|
+
break;
|
336
|
+
}
|
337
|
+
}
|
338
|
+
}
|
339
|
+
|
340
|
+
while (true) {
|
341
|
+
increment(date);
|
342
|
+
if (date > max) break;
|
343
|
+
dates.push(new Date(date));
|
344
|
+
}
|
345
|
+
return reverse ? dates.reverse() : dates;
|
346
|
+
}
|
347
|
+
|
348
|
+
/* Normal case: numbers. */
|
349
|
+
if (!arguments.length) m = 10;
|
350
|
+
var step = pv.logFloor(span / m, 10),
|
351
|
+
err = m / (span / step);
|
352
|
+
if (err <= .15) step *= 10;
|
353
|
+
else if (err <= .35) step *= 5;
|
354
|
+
else if (err <= .75) step *= 2;
|
355
|
+
var start = Math.ceil(min / step) * step,
|
356
|
+
end = Math.floor(max / step) * step;
|
357
|
+
tickFormat = pv.Format.number()
|
358
|
+
.fractionDigits(Math.max(0, -Math.floor(pv.log(step, 10) + .01)));
|
359
|
+
var ticks = pv.range(start, end + step, step);
|
360
|
+
return reverse ? ticks.reverse() : ticks;
|
361
|
+
};
|
362
|
+
|
363
|
+
/**
|
364
|
+
* Formats the specified tick value using the appropriate precision, based on
|
365
|
+
* the step interval between tick marks. If {@link #ticks} has not been called,
|
366
|
+
* the argument is converted to a string, but no formatting is applied.
|
367
|
+
*
|
368
|
+
* @function
|
369
|
+
* @name pv.Scale.quantitative.prototype.tickFormat
|
370
|
+
* @param {number} t a tick value.
|
371
|
+
* @returns {string} a formatted tick value.
|
372
|
+
*/
|
373
|
+
scale.tickFormat = function (t) { return tickFormat(t); };
|
374
|
+
|
375
|
+
/**
|
376
|
+
* "Nices" this scale, extending the bounds of the input domain to
|
377
|
+
* evenly-rounded values. Nicing is useful if the domain is computed
|
378
|
+
* dynamically from data, and may be irregular. For example, given a domain of
|
379
|
+
* [0.20147987687960267, 0.996679553296417], a call to <tt>nice()</tt> might
|
380
|
+
* extend the domain to [0.2, 1].
|
381
|
+
*
|
382
|
+
* <p>This method must be invoked each time after setting the domain.
|
383
|
+
*
|
384
|
+
* @function
|
385
|
+
* @name pv.Scale.quantitative.prototype.nice
|
386
|
+
* @returns {pv.Scale.quantitative} <tt>this</tt>.
|
387
|
+
*/
|
388
|
+
scale.nice = function() {
|
389
|
+
if (d.length != 2) return this; // TODO support non-uniform domains
|
390
|
+
var start = d[0],
|
391
|
+
end = d[d.length - 1],
|
392
|
+
reverse = end < start,
|
393
|
+
min = reverse ? end : start,
|
394
|
+
max = reverse ? start : end,
|
395
|
+
span = max - min;
|
396
|
+
|
397
|
+
/* Special case: empty, invalid or infinite span. */
|
398
|
+
if (!span || !isFinite(span)) return this;
|
399
|
+
|
400
|
+
var step = Math.pow(10, Math.round(Math.log(span) / Math.log(10)) - 1);
|
401
|
+
d = [Math.floor(min / step) * step, Math.ceil(max / step) * step];
|
402
|
+
if (reverse) d.reverse();
|
403
|
+
l = d.map(f);
|
404
|
+
return this;
|
405
|
+
};
|
406
|
+
|
407
|
+
/**
|
408
|
+
* Returns a view of this scale by the specified accessor function <tt>f</tt>.
|
409
|
+
* Given a scale <tt>y</tt>, <tt>y.by(function(d) d.foo)</tt> is equivalent to
|
410
|
+
* <tt>function(d) y(d.foo)</tt>.
|
411
|
+
*
|
412
|
+
* <p>This method is provided for convenience, such that scales can be
|
413
|
+
* succinctly defined inline. For example, given an array of data elements
|
414
|
+
* that have a <tt>score</tt> attribute with the domain [0, 1], the height
|
415
|
+
* property could be specified as:
|
416
|
+
*
|
417
|
+
* <pre> .height(pv.Scale.linear().range(0, 480).by(function(d) d.score))</pre>
|
418
|
+
*
|
419
|
+
* This is equivalent to:
|
420
|
+
*
|
421
|
+
* <pre> .height(function(d) d.score * 480)</pre>
|
422
|
+
*
|
423
|
+
* This method should be used judiciously; it is typically more clear to
|
424
|
+
* invoke the scale directly, passing in the value to be scaled.
|
425
|
+
*
|
426
|
+
* @function
|
427
|
+
* @name pv.Scale.quantitative.prototype.by
|
428
|
+
* @param {function} f an accessor function.
|
429
|
+
* @returns {pv.Scale.quantitative} a view of this scale by the specified
|
430
|
+
* accessor function.
|
431
|
+
*/
|
432
|
+
scale.by = function(f) {
|
433
|
+
function by() { return scale(f.apply(this, arguments)); }
|
434
|
+
for (var method in scale) by[method] = scale[method];
|
435
|
+
return by;
|
436
|
+
};
|
437
|
+
|
438
|
+
scale.domain.apply(scale, arguments);
|
439
|
+
return scale;
|
440
|
+
};
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/**
|
2
|
+
* Returns a root scale for the specified domain. The arguments to this
|
3
|
+
* constructor are optional, and equivalent to calling {@link #domain}.
|
4
|
+
* The default domain and range are [0,1].
|
5
|
+
*
|
6
|
+
* @class Represents a root scale; a function that performs a power
|
7
|
+
* transformation. <style type="text/css">sub{line-height:0}</style> Most
|
8
|
+
* commonly, a root scale represents a 1-dimensional root transformation from a
|
9
|
+
* numeric domain of input data [<i>d<sub>0</sub></i>, <i>d<sub>1</sub></i>] to
|
10
|
+
* a numeric range of pixels [<i>r<sub>0</sub></i>, <i>r<sub>1</sub></i>].
|
11
|
+
*
|
12
|
+
* <p>Note that the scale is itself a function, and thus can be used as a
|
13
|
+
* property directly, assuming that the data associated with a mark is a
|
14
|
+
* number. While this is convenient for single-use scales, frequently it is
|
15
|
+
* desirable to define scales globally:
|
16
|
+
*
|
17
|
+
* <pre>var y = pv.Scale.root(0, 100).range(0, 640);</pre>
|
18
|
+
*
|
19
|
+
* The <tt>y</tt> scale can now be equivalently referenced within a property:
|
20
|
+
*
|
21
|
+
* <pre> .height(function(d) y(d))</pre>
|
22
|
+
*
|
23
|
+
* Alternatively, if the data are not simple numbers, the appropriate value can
|
24
|
+
* be passed to the <tt>y</tt> scale (e.g., <tt>d.foo</tt>). The {@link #by}
|
25
|
+
* method similarly allows the data to be mapped to a numeric value before
|
26
|
+
* performing the root transformation.
|
27
|
+
*
|
28
|
+
* @param {number...} domain... optional domain values.
|
29
|
+
* @extends pv.Scale.quantitative
|
30
|
+
*/
|
31
|
+
pv.Scale.root = function() {
|
32
|
+
var scale = pv.Scale.quantitative();
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Sets or gets the exponent; defaults to 2.
|
36
|
+
*
|
37
|
+
* @function
|
38
|
+
* @name pv.Scale.root.prototype.power
|
39
|
+
* @param {number} [v] the new exponent.
|
40
|
+
* @returns {pv.Scale.root} <tt>this</tt>, or the current base.
|
41
|
+
*/
|
42
|
+
scale.power = function(v) {
|
43
|
+
if (arguments.length) {
|
44
|
+
var b = Number(v), p = 1 / b;
|
45
|
+
scale.transform(
|
46
|
+
function(x) { return Math.pow(x, p); },
|
47
|
+
function(y) { return Math.pow(y, b); });
|
48
|
+
return this;
|
49
|
+
}
|
50
|
+
return b;
|
51
|
+
};
|
52
|
+
|
53
|
+
scale.domain.apply(scale, arguments);
|
54
|
+
return scale.power(2);
|
55
|
+
};
|