rubyvis 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.travis.yml +13 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +37 -0
- data/History.txt +6 -0
- data/LICENSE.txt +23 -0
- data/{README.txt → README.md} +15 -12
- data/Rakefile +4 -11
- data/lib/rubyvis.rb +1 -1
- data/lib/rubyvis/scale/quantitative.rb +14 -18
- data/lib/rubyvis/scene/svg_label.rb +1 -1
- data/rubyvis.gemspec +21 -0
- data/spec/anchor_spec.rb +2 -1
- data/spec/line_spec.rb +2 -2
- data/spec/scale_linear_datetime_spec.rb +23 -8
- data/spec/spec_helper.rb +2 -1
- metadata +31 -214
- data/.gemtest +0 -0
- data/vendor/protovis/protovis-r3.3.js +0 -287
- data/vendor/protovis/src/behavior/Behavior.js +0 -32
- data/vendor/protovis/src/behavior/Drag.js +0 -112
- data/vendor/protovis/src/behavior/Pan.js +0 -110
- data/vendor/protovis/src/behavior/Point.js +0 -157
- data/vendor/protovis/src/behavior/Resize.js +0 -104
- data/vendor/protovis/src/behavior/Select.js +0 -100
- data/vendor/protovis/src/behavior/Zoom.js +0 -85
- data/vendor/protovis/src/color/Color.js +0 -598
- data/vendor/protovis/src/color/Colors.js +0 -135
- data/vendor/protovis/src/color/Ramp.js +0 -17
- data/vendor/protovis/src/data/Arrays.js +0 -277
- data/vendor/protovis/src/data/Dom.js +0 -380
- data/vendor/protovis/src/data/Flatten.js +0 -146
- data/vendor/protovis/src/data/Histogram.js +0 -120
- data/vendor/protovis/src/data/LinearScale.js +0 -54
- data/vendor/protovis/src/data/LogScale.js +0 -142
- data/vendor/protovis/src/data/Nest.js +0 -257
- data/vendor/protovis/src/data/Numbers.js +0 -313
- data/vendor/protovis/src/data/Objects.js +0 -78
- data/vendor/protovis/src/data/OrdinalScale.js +0 -267
- data/vendor/protovis/src/data/QuantileScale.js +0 -180
- data/vendor/protovis/src/data/QuantitativeScale.js +0 -440
- data/vendor/protovis/src/data/RootScale.js +0 -55
- data/vendor/protovis/src/data/Scale.js +0 -86
- data/vendor/protovis/src/data/Transform.js +0 -109
- data/vendor/protovis/src/data/Tree.js +0 -124
- data/vendor/protovis/src/data/Vector.js +0 -118
- data/vendor/protovis/src/geo/Geo.js +0 -5
- data/vendor/protovis/src/geo/GeoScale.js +0 -307
- data/vendor/protovis/src/geo/LatLng.js +0 -23
- data/vendor/protovis/src/geo/Projection.js +0 -43
- data/vendor/protovis/src/geo/Projections.js +0 -117
- data/vendor/protovis/src/lang/Array.js +0 -112
- data/vendor/protovis/src/lang/init.js +0 -26
- data/vendor/protovis/src/layout/Arc.js +0 -178
- data/vendor/protovis/src/layout/Bullet.js +0 -164
- data/vendor/protovis/src/layout/Cluster.js +0 -205
- data/vendor/protovis/src/layout/Force.js +0 -309
- data/vendor/protovis/src/layout/Grid.js +0 -119
- data/vendor/protovis/src/layout/Hierarchy.js +0 -249
- data/vendor/protovis/src/layout/Horizon.js +0 -159
- data/vendor/protovis/src/layout/Indent.js +0 -83
- data/vendor/protovis/src/layout/Layout.js +0 -56
- data/vendor/protovis/src/layout/Matrix.js +0 -177
- data/vendor/protovis/src/layout/Network.js +0 -302
- data/vendor/protovis/src/layout/Pack.js +0 -323
- data/vendor/protovis/src/layout/Partition.js +0 -203
- data/vendor/protovis/src/layout/Rollup.js +0 -203
- data/vendor/protovis/src/layout/Stack.js +0 -391
- data/vendor/protovis/src/layout/Tree.js +0 -282
- data/vendor/protovis/src/layout/Treemap.js +0 -347
- data/vendor/protovis/src/mark/Anchor.js +0 -81
- data/vendor/protovis/src/mark/Area.js +0 -268
- data/vendor/protovis/src/mark/Bar.js +0 -93
- data/vendor/protovis/src/mark/Dot.js +0 -212
- data/vendor/protovis/src/mark/Ease.js +0 -150
- data/vendor/protovis/src/mark/Image.js +0 -154
- data/vendor/protovis/src/mark/Label.js +0 -155
- data/vendor/protovis/src/mark/Line.js +0 -195
- data/vendor/protovis/src/mark/Mark.js +0 -1237
- data/vendor/protovis/src/mark/Panel.js +0 -273
- data/vendor/protovis/src/mark/Rule.js +0 -143
- data/vendor/protovis/src/mark/Transient.js +0 -7
- data/vendor/protovis/src/mark/Transition.js +0 -195
- data/vendor/protovis/src/mark/Wedge.js +0 -244
- data/vendor/protovis/src/physics/BoundConstraint.js +0 -75
- data/vendor/protovis/src/physics/ChargeForce.js +0 -184
- data/vendor/protovis/src/physics/CollisionConstraint.js +0 -113
- data/vendor/protovis/src/physics/Constraint.js +0 -26
- data/vendor/protovis/src/physics/DragForce.js +0 -49
- data/vendor/protovis/src/physics/Force.js +0 -25
- data/vendor/protovis/src/physics/Particle.js +0 -81
- data/vendor/protovis/src/physics/PositionConstraint.js +0 -72
- data/vendor/protovis/src/physics/Quadtree.js +0 -195
- data/vendor/protovis/src/physics/Simulation.js +0 -159
- data/vendor/protovis/src/physics/SpringForce.js +0 -141
- data/vendor/protovis/src/pv-internals.js +0 -154
- data/vendor/protovis/src/pv.js +0 -95
- data/vendor/protovis/src/scene/SvgArea.js +0 -172
- data/vendor/protovis/src/scene/SvgBar.js +0 -28
- data/vendor/protovis/src/scene/SvgCurve.js +0 -354
- data/vendor/protovis/src/scene/SvgDot.js +0 -81
- data/vendor/protovis/src/scene/SvgImage.js +0 -45
- data/vendor/protovis/src/scene/SvgLabel.js +0 -46
- data/vendor/protovis/src/scene/SvgLine.js +0 -159
- data/vendor/protovis/src/scene/SvgPanel.js +0 -126
- data/vendor/protovis/src/scene/SvgRule.js +0 -26
- data/vendor/protovis/src/scene/SvgScene.js +0 -185
- data/vendor/protovis/src/scene/SvgWedge.js +0 -66
- data/vendor/protovis/src/text/DateFormat.js +0 -262
- data/vendor/protovis/src/text/Format.js +0 -78
- data/vendor/protovis/src/text/NumberFormat.js +0 -227
- data/vendor/protovis/src/text/TimeFormat.js +0 -115
@@ -1,150 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* TERMS OF USE - EASING EQUATIONS
|
3
|
-
*
|
4
|
-
* Open source under the BSD License.
|
5
|
-
*
|
6
|
-
* Copyright 2001 Robert Penner
|
7
|
-
* All rights reserved.
|
8
|
-
*
|
9
|
-
* Redistribution and use in source and binary forms, with or without
|
10
|
-
* modification, are permitted provided that the following conditions are met:
|
11
|
-
*
|
12
|
-
* - Redistributions of source code must retain the above copyright notice, this
|
13
|
-
* list of conditions and the following disclaimer.
|
14
|
-
*
|
15
|
-
* - Redistributions in binary form must reproduce the above copyright notice,
|
16
|
-
* this list of conditions and the following disclaimer in the documentation
|
17
|
-
* and/or other materials provided with the distribution.
|
18
|
-
*
|
19
|
-
* - Neither the name of the author nor the names of contributors may be used to
|
20
|
-
* endorse or promote products derived from this software without specific
|
21
|
-
* prior written permission.
|
22
|
-
*
|
23
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
26
|
-
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
27
|
-
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
28
|
-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
29
|
-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
30
|
-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
31
|
-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
32
|
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
33
|
-
* POSSIBILITY OF SUCH DAMAGE.
|
34
|
-
*/
|
35
|
-
|
36
|
-
pv.Ease = (function() {
|
37
|
-
|
38
|
-
function reverse(f) {
|
39
|
-
return function(t) {
|
40
|
-
return 1 - f(1 - t);
|
41
|
-
};
|
42
|
-
}
|
43
|
-
|
44
|
-
function reflect(f) {
|
45
|
-
return function(t) {
|
46
|
-
return .5 * (t < .5 ? f(2 * t) : (2 - f(2 - 2 * t)));
|
47
|
-
};
|
48
|
-
}
|
49
|
-
|
50
|
-
function poly(e) {
|
51
|
-
return function(t) {
|
52
|
-
return t < 0 ? 0 : t > 1 ? 1 : Math.pow(t, e);
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
function sin(t) {
|
57
|
-
return 1 - Math.cos(t * Math.PI / 2);
|
58
|
-
}
|
59
|
-
|
60
|
-
function exp(t) {
|
61
|
-
return t ? Math.pow(2, 10 * (t - 1)) - 0.001 : 0;
|
62
|
-
}
|
63
|
-
|
64
|
-
function circle(t) {
|
65
|
-
return -(Math.sqrt(1 - t * t) - 1);
|
66
|
-
}
|
67
|
-
|
68
|
-
function elastic(a, p) {
|
69
|
-
var s;
|
70
|
-
if (!p) p = 0.45;
|
71
|
-
if (!a || a < 1) { a = 1; s = p / 4; }
|
72
|
-
else s = p / (2 * Math.PI) * Math.asin(1 / a);
|
73
|
-
return function(t) {
|
74
|
-
return t <= 0 || t >= 1 ? t
|
75
|
-
: -(a * Math.pow(2, 10 * (--t)) * Math.sin((t - s) * (2 * Math.PI) / p));
|
76
|
-
};
|
77
|
-
}
|
78
|
-
|
79
|
-
function back(s) {
|
80
|
-
if (!s) s = 1.70158;
|
81
|
-
return function(t) {
|
82
|
-
return t * t * ((s + 1) * t - s);
|
83
|
-
};
|
84
|
-
}
|
85
|
-
|
86
|
-
function bounce(t) {
|
87
|
-
return t < 1 / 2.75 ? 7.5625 * t * t
|
88
|
-
: t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75
|
89
|
-
: t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375
|
90
|
-
: 7.5625 * (t -= 2.625 / 2.75) * t + .984375;
|
91
|
-
}
|
92
|
-
|
93
|
-
var quad = poly(2),
|
94
|
-
cubic = poly(3),
|
95
|
-
elasticDefault = elastic(),
|
96
|
-
backDefault = back();
|
97
|
-
|
98
|
-
var eases = {
|
99
|
-
"linear": pv.identity,
|
100
|
-
"quad-in": quad,
|
101
|
-
"quad-out": reverse(quad),
|
102
|
-
"quad-in-out": reflect(quad),
|
103
|
-
"quad-out-in": reflect(reverse(quad)),
|
104
|
-
"cubic-in": cubic,
|
105
|
-
"cubic-out": reverse(cubic),
|
106
|
-
"cubic-in-out": reflect(cubic),
|
107
|
-
"cubic-out-in": reflect(reverse(cubic)),
|
108
|
-
"sin-in": sin,
|
109
|
-
"sin-out": reverse(sin),
|
110
|
-
"sin-in-out": reflect(sin),
|
111
|
-
"sin-out-in": reflect(reverse(sin)),
|
112
|
-
"exp-in": exp,
|
113
|
-
"exp-out": reverse(exp),
|
114
|
-
"exp-in-out": reflect(exp),
|
115
|
-
"exp-out-in": reflect(reverse(exp)),
|
116
|
-
"circle-in": circle,
|
117
|
-
"circle-out": reverse(circle),
|
118
|
-
"circle-in-out": reflect(circle),
|
119
|
-
"circle-out-in": reflect(reverse(circle)),
|
120
|
-
"elastic-in": elasticDefault,
|
121
|
-
"elastic-out": reverse(elasticDefault),
|
122
|
-
"elastic-in-out": reflect(elasticDefault),
|
123
|
-
"elastic-out-in": reflect(reverse(elasticDefault)),
|
124
|
-
"back-in": backDefault,
|
125
|
-
"back-out": reverse(backDefault),
|
126
|
-
"back-in-out": reflect(backDefault),
|
127
|
-
"back-out-in": reflect(reverse(backDefault)),
|
128
|
-
"bounce-in": bounce,
|
129
|
-
"bounce-out": reverse(bounce),
|
130
|
-
"bounce-in-out": reflect(bounce),
|
131
|
-
"bounce-out-in": reflect(reverse(bounce))
|
132
|
-
};
|
133
|
-
|
134
|
-
pv.ease = function(f) {
|
135
|
-
return eases[f];
|
136
|
-
};
|
137
|
-
|
138
|
-
return {
|
139
|
-
reverse: reverse,
|
140
|
-
reflect: reflect,
|
141
|
-
linear: function() { return pv.identity; },
|
142
|
-
sin: function() { return sin; },
|
143
|
-
exp: function() { return exp; },
|
144
|
-
circle: function() { return circle; },
|
145
|
-
elastic: elastic,
|
146
|
-
back: back,
|
147
|
-
bounce: bounce,
|
148
|
-
poly: poly
|
149
|
-
};
|
150
|
-
})();
|
@@ -1,154 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Constructs a new image with default properties. Images are not typically
|
3
|
-
* constructed directly, but by adding to a panel or an existing mark via
|
4
|
-
* {@link pv.Mark#add}.
|
5
|
-
*
|
6
|
-
* @class Represents an image, either a static resource or a dynamically-
|
7
|
-
* generated pixel buffer. Images share the same layout and style properties as
|
8
|
-
* bars. The external image resource is specified via the {@link #url}
|
9
|
-
* property. The optional fill, if specified, appears beneath the image, while
|
10
|
-
* the optional stroke appears above the image.
|
11
|
-
*
|
12
|
-
* <p>Dynamic images such as heatmaps are supported using the {@link #image}
|
13
|
-
* psuedo-property. This function is passed the <i>x</i> and <i>y</i> index, in
|
14
|
-
* addition to the current data stack. The return value is a {@link pv.Color},
|
15
|
-
* or null for transparent. A string can also be returned, which will be parsed
|
16
|
-
* into a color; however, it is typically much faster to return an object with
|
17
|
-
* <tt>r</tt>, <tt>g</tt>, <tt>b</tt> and <tt>a</tt> attributes, to avoid the
|
18
|
-
* cost of parsing and object instantiation.
|
19
|
-
*
|
20
|
-
* <p>See {@link pv.Bar} for details on positioning properties.
|
21
|
-
*
|
22
|
-
* @extends pv.Bar
|
23
|
-
*/
|
24
|
-
pv.Image = function() {
|
25
|
-
pv.Bar.call(this);
|
26
|
-
};
|
27
|
-
|
28
|
-
pv.Image.prototype = pv.extend(pv.Bar)
|
29
|
-
.property("url", String)
|
30
|
-
.property("imageWidth", Number)
|
31
|
-
.property("imageHeight", Number);
|
32
|
-
|
33
|
-
pv.Image.prototype.type = "image";
|
34
|
-
|
35
|
-
/**
|
36
|
-
* The URL of the image to display. The set of supported image types is
|
37
|
-
* browser-dependent; PNG and JPEG are recommended.
|
38
|
-
*
|
39
|
-
* @type string
|
40
|
-
* @name pv.Image.prototype.url
|
41
|
-
*/
|
42
|
-
|
43
|
-
/**
|
44
|
-
* The width of the image in pixels. For static images, this property is
|
45
|
-
* computed implicitly from the loaded image resources. For dynamic images, this
|
46
|
-
* property can be used to specify the width of the pixel buffer; otherwise, the
|
47
|
-
* value is derived from the <tt>width</tt> property.
|
48
|
-
*
|
49
|
-
* @type number
|
50
|
-
* @name pv.Image.prototype.imageWidth
|
51
|
-
*/
|
52
|
-
|
53
|
-
/**
|
54
|
-
* The height of the image in pixels. For static images, this property is
|
55
|
-
* computed implicitly from the loaded image resources. For dynamic images, this
|
56
|
-
* property can be used to specify the height of the pixel buffer; otherwise, the
|
57
|
-
* value is derived from the <tt>height</tt> property.
|
58
|
-
*
|
59
|
-
* @type number
|
60
|
-
* @name pv.Image.prototype.imageHeight
|
61
|
-
*/
|
62
|
-
|
63
|
-
/**
|
64
|
-
* Default properties for images. By default, there is no stroke or fill style.
|
65
|
-
*
|
66
|
-
* @type pv.Image
|
67
|
-
*/
|
68
|
-
pv.Image.prototype.defaults = new pv.Image()
|
69
|
-
.extend(pv.Bar.prototype.defaults)
|
70
|
-
.fillStyle(null);
|
71
|
-
|
72
|
-
/**
|
73
|
-
* Specifies the dynamic image function. By default, no image function is
|
74
|
-
* specified and the <tt>url</tt> property is used to load a static image
|
75
|
-
* resource. If an image function is specified, it will be invoked for each
|
76
|
-
* pixel in the image, based on the related <tt>imageWidth</tt> and
|
77
|
-
* <tt>imageHeight</tt> properties.
|
78
|
-
*
|
79
|
-
* <p>For example, given a two-dimensional array <tt>heatmap</tt>, containing
|
80
|
-
* numbers in the range [0, 1] in row-major order, a simple monochrome heatmap
|
81
|
-
* image can be specified as:
|
82
|
-
*
|
83
|
-
* <pre>vis.add(pv.Image)
|
84
|
-
* .imageWidth(heatmap[0].length)
|
85
|
-
* .imageHeight(heatmap.length)
|
86
|
-
* .image(pv.ramp("white", "black").by(function(x, y) heatmap[y][x]));</pre>
|
87
|
-
*
|
88
|
-
* For fastest performance, use an ordinal scale which caches the fixed color
|
89
|
-
* palette, or return an object literal with <tt>r</tt>, <tt>g</tt>, <tt>b</tt>
|
90
|
-
* and <tt>a</tt> attributes. A {@link pv.Color} or string can also be returned,
|
91
|
-
* though this typically results in slower performance.
|
92
|
-
*
|
93
|
-
* @param {function} f the new sizing function.
|
94
|
-
* @returns {pv.Layout.Pack} this.
|
95
|
-
*/
|
96
|
-
pv.Image.prototype.image = function(f) {
|
97
|
-
/** @private */
|
98
|
-
this.$image = function() {
|
99
|
-
var c = f.apply(this, arguments);
|
100
|
-
return c == null ? pv.Color.transparent
|
101
|
-
: typeof c == "string" ? pv.color(c)
|
102
|
-
: c;
|
103
|
-
};
|
104
|
-
return this;
|
105
|
-
};
|
106
|
-
|
107
|
-
/** @private Scan the proto chain for an image function. */
|
108
|
-
pv.Image.prototype.bind = function() {
|
109
|
-
pv.Bar.prototype.bind.call(this);
|
110
|
-
var binds = this.binds, mark = this;
|
111
|
-
do {
|
112
|
-
binds.image = mark.$image;
|
113
|
-
} while (!binds.image && (mark = mark.proto));
|
114
|
-
};
|
115
|
-
|
116
|
-
/** @private */
|
117
|
-
pv.Image.prototype.buildImplied = function(s) {
|
118
|
-
pv.Bar.prototype.buildImplied.call(this, s);
|
119
|
-
if (!s.visible) return;
|
120
|
-
|
121
|
-
/* Compute the implied image dimensions. */
|
122
|
-
if (s.imageWidth == null) s.imageWidth = s.width;
|
123
|
-
if (s.imageHeight == null) s.imageHeight = s.height;
|
124
|
-
|
125
|
-
/* Compute the pixel values. */
|
126
|
-
if ((s.url == null) && this.binds.image) {
|
127
|
-
|
128
|
-
/* Cache the canvas element to reuse across renders. */
|
129
|
-
var canvas = this.$canvas || (this.$canvas = document.createElement("canvas")),
|
130
|
-
context = canvas.getContext("2d"),
|
131
|
-
w = s.imageWidth,
|
132
|
-
h = s.imageHeight,
|
133
|
-
stack = pv.Mark.stack,
|
134
|
-
data;
|
135
|
-
|
136
|
-
/* Evaluate the image function, storing into a CanvasPixelArray. */
|
137
|
-
canvas.width = w;
|
138
|
-
canvas.height = h;
|
139
|
-
data = (s.image = context.createImageData(w, h)).data;
|
140
|
-
stack.unshift(null, null);
|
141
|
-
for (var y = 0, p = 0; y < h; y++) {
|
142
|
-
stack[1] = y;
|
143
|
-
for (var x = 0; x < w; x++) {
|
144
|
-
stack[0] = x;
|
145
|
-
var color = this.binds.image.apply(this, stack);
|
146
|
-
data[p++] = color.r;
|
147
|
-
data[p++] = color.g;
|
148
|
-
data[p++] = color.b;
|
149
|
-
data[p++] = 255 * color.a;
|
150
|
-
}
|
151
|
-
}
|
152
|
-
stack.splice(0, 2);
|
153
|
-
}
|
154
|
-
};
|
@@ -1,155 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Constructs a new label mark with default properties. Labels are not typically
|
3
|
-
* constructed directly, but by adding to a panel or an existing mark via
|
4
|
-
* {@link pv.Mark#add}.
|
5
|
-
*
|
6
|
-
* @class Represents a text label, allowing textual annotation of other marks or
|
7
|
-
* arbitrary text within the visualization. The character data must be plain
|
8
|
-
* text (unicode), though the text can be styled using the {@link #font}
|
9
|
-
* property. If rich text is needed, external HTML elements can be overlaid on
|
10
|
-
* the canvas by hand.
|
11
|
-
*
|
12
|
-
* <p>Labels are positioned using the box model, similarly to {@link Dot}. Thus,
|
13
|
-
* a label has no width or height, but merely a text anchor location. The text
|
14
|
-
* is positioned relative to this anchor location based on the
|
15
|
-
* {@link #textAlign}, {@link #textBaseline} and {@link #textMargin} properties.
|
16
|
-
* Furthermore, the text may be rotated using {@link #textAngle}.
|
17
|
-
*
|
18
|
-
* <p>Labels ignore events, so as to not interfere with event handlers on
|
19
|
-
* underlying marks, such as bars. In the future, we may support event handlers
|
20
|
-
* on labels.
|
21
|
-
*
|
22
|
-
* <p>See also the <a href="../../api/Label.html">Label guide</a>.
|
23
|
-
*
|
24
|
-
* @extends pv.Mark
|
25
|
-
*/
|
26
|
-
pv.Label = function() {
|
27
|
-
pv.Mark.call(this);
|
28
|
-
};
|
29
|
-
|
30
|
-
pv.Label.prototype = pv.extend(pv.Mark)
|
31
|
-
.property("text", String)
|
32
|
-
.property("font", String)
|
33
|
-
.property("textAngle", Number)
|
34
|
-
.property("textStyle", pv.color)
|
35
|
-
.property("textAlign", String)
|
36
|
-
.property("textBaseline", String)
|
37
|
-
.property("textMargin", Number)
|
38
|
-
.property("textDecoration", String)
|
39
|
-
.property("textShadow", String);
|
40
|
-
|
41
|
-
pv.Label.prototype.type = "label";
|
42
|
-
|
43
|
-
/**
|
44
|
-
* The character data to render; a string. The default value of the text
|
45
|
-
* property is the identity function, meaning the label's associated datum will
|
46
|
-
* be rendered using its <tt>toString</tt>.
|
47
|
-
*
|
48
|
-
* @type string
|
49
|
-
* @name pv.Label.prototype.text
|
50
|
-
*/
|
51
|
-
|
52
|
-
/**
|
53
|
-
* The font format, per the CSS Level 2 specification. The default font is "10px
|
54
|
-
* sans-serif", for consistency with the HTML 5 canvas element specification.
|
55
|
-
* Note that since text is not wrapped, any line-height property will be
|
56
|
-
* ignored. The other font-style, font-variant, font-weight, font-size and
|
57
|
-
* font-family properties are supported.
|
58
|
-
*
|
59
|
-
* @see <a href="http://www.w3.org/TR/CSS2/fonts.html#font-shorthand">CSS2 fonts</a>
|
60
|
-
* @type string
|
61
|
-
* @name pv.Label.prototype.font
|
62
|
-
*/
|
63
|
-
|
64
|
-
/**
|
65
|
-
* The rotation angle, in radians. Text is rotated clockwise relative to the
|
66
|
-
* anchor location. For example, with the default left alignment, an angle of
|
67
|
-
* Math.PI / 2 causes text to proceed downwards. The default angle is zero.
|
68
|
-
*
|
69
|
-
* @type number
|
70
|
-
* @name pv.Label.prototype.textAngle
|
71
|
-
*/
|
72
|
-
|
73
|
-
/**
|
74
|
-
* The text color. The name "textStyle" is used for consistency with "fillStyle"
|
75
|
-
* and "strokeStyle", although it might be better to rename this property (and
|
76
|
-
* perhaps use the same name as "strokeStyle"). The default color is black.
|
77
|
-
*
|
78
|
-
* @type string
|
79
|
-
* @name pv.Label.prototype.textStyle
|
80
|
-
* @see pv.color
|
81
|
-
*/
|
82
|
-
|
83
|
-
/**
|
84
|
-
* The horizontal text alignment. One of:<ul>
|
85
|
-
*
|
86
|
-
* <li>left
|
87
|
-
* <li>center
|
88
|
-
* <li>right
|
89
|
-
*
|
90
|
-
* </ul>The default horizontal alignment is left.
|
91
|
-
*
|
92
|
-
* @type string
|
93
|
-
* @name pv.Label.prototype.textAlign
|
94
|
-
*/
|
95
|
-
|
96
|
-
/**
|
97
|
-
* The vertical text alignment. One of:<ul>
|
98
|
-
*
|
99
|
-
* <li>top
|
100
|
-
* <li>middle
|
101
|
-
* <li>bottom
|
102
|
-
*
|
103
|
-
* </ul>The default vertical alignment is bottom.
|
104
|
-
*
|
105
|
-
* @type string
|
106
|
-
* @name pv.Label.prototype.textBaseline
|
107
|
-
*/
|
108
|
-
|
109
|
-
/**
|
110
|
-
* The text margin; may be specified in pixels, or in font-dependent units (such
|
111
|
-
* as ".1ex"). The margin can be used to pad text away from its anchor location,
|
112
|
-
* in a direction dependent on the horizontal and vertical alignment
|
113
|
-
* properties. For example, if the text is left- and middle-aligned, the margin
|
114
|
-
* shifts the text to the right. The default margin is 3 pixels.
|
115
|
-
*
|
116
|
-
* @type number
|
117
|
-
* @name pv.Label.prototype.textMargin
|
118
|
-
*/
|
119
|
-
|
120
|
-
/**
|
121
|
-
* A list of shadow effects to be applied to text, per the CSS Text Level 3
|
122
|
-
* text-shadow property. An example specification is "0.1em 0.1em 0.1em
|
123
|
-
* rgba(0,0,0,.5)"; the first length is the horizontal offset, the second the
|
124
|
-
* vertical offset, and the third the blur radius.
|
125
|
-
*
|
126
|
-
* @see <a href="http://www.w3.org/TR/css3-text/#text-shadow">CSS3 text</a>
|
127
|
-
* @type string
|
128
|
-
* @name pv.Label.prototype.textShadow
|
129
|
-
*/
|
130
|
-
|
131
|
-
/**
|
132
|
-
* A list of decoration to be applied to text, per the CSS Text Level 3
|
133
|
-
* text-decoration property. An example specification is "underline".
|
134
|
-
*
|
135
|
-
* @see <a href="http://www.w3.org/TR/css3-text/#text-decoration">CSS3 text</a>
|
136
|
-
* @type string
|
137
|
-
* @name pv.Label.prototype.textDecoration
|
138
|
-
*/
|
139
|
-
|
140
|
-
/**
|
141
|
-
* Default properties for labels. See the individual properties for the default
|
142
|
-
* values.
|
143
|
-
*
|
144
|
-
* @type pv.Label
|
145
|
-
*/
|
146
|
-
pv.Label.prototype.defaults = new pv.Label()
|
147
|
-
.extend(pv.Mark.prototype.defaults)
|
148
|
-
.events("none")
|
149
|
-
.text(pv.identity)
|
150
|
-
.font("10px sans-serif")
|
151
|
-
.textAngle(0)
|
152
|
-
.textStyle("black")
|
153
|
-
.textAlign("left")
|
154
|
-
.textBaseline("bottom")
|
155
|
-
.textMargin(3);
|