rgraph-rails 5.00 → 6.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/publish-geml.yaml +46 -0
- data/.gitignore +1 -0
- data/README.md +4 -5
- data/lib/rgraph-rails/version.rb +1 -1
- data/rgraph-rails.gemspec +4 -4
- data/vendor/assets/javascripts/RGraph.activity.js +1691 -0
- data/vendor/assets/javascripts/RGraph.bar.js +4253 -236
- data/vendor/assets/javascripts/RGraph.bipolar.js +3958 -162
- data/vendor/assets/javascripts/RGraph.common.annotate.js +414 -35
- data/vendor/assets/javascripts/RGraph.common.context.js +635 -30
- data/vendor/assets/javascripts/RGraph.common.core.js +10485 -419
- data/vendor/assets/javascripts/RGraph.common.csv.js +508 -27
- data/vendor/assets/javascripts/RGraph.common.dynamic.js +1693 -90
- data/vendor/assets/javascripts/RGraph.common.effects.js +1629 -89
- data/vendor/assets/javascripts/RGraph.common.key.js +1003 -53
- data/vendor/assets/javascripts/RGraph.common.moment.js +5670 -0
- data/vendor/assets/javascripts/RGraph.common.sheets.js +541 -31
- data/vendor/assets/javascripts/RGraph.common.sheets.php +351 -0
- data/vendor/assets/javascripts/RGraph.common.starburst.js +382 -0
- data/vendor/assets/javascripts/RGraph.common.table.js +386 -0
- data/vendor/assets/javascripts/RGraph.common.tooltips.js +1433 -32
- data/vendor/assets/javascripts/RGraph.drawing.background.js +660 -35
- data/vendor/assets/javascripts/RGraph.drawing.circle.js +618 -34
- data/vendor/assets/javascripts/RGraph.drawing.image.js +857 -52
- data/vendor/assets/javascripts/RGraph.drawing.line.js +712 -0
- data/vendor/assets/javascripts/RGraph.drawing.marker1.js +760 -38
- data/vendor/assets/javascripts/RGraph.drawing.marker2.js +740 -37
- data/vendor/assets/javascripts/RGraph.drawing.marker3.js +573 -36
- data/vendor/assets/javascripts/RGraph.drawing.poly.js +667 -36
- data/vendor/assets/javascripts/RGraph.drawing.rect.js +638 -34
- data/vendor/assets/javascripts/RGraph.drawing.text.js +672 -37
- data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +653 -52
- data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +714 -51
- data/vendor/assets/javascripts/RGraph.fuel.js +1149 -59
- data/vendor/assets/javascripts/RGraph.funnel.js +1277 -56
- data/vendor/assets/javascripts/RGraph.gantt.js +1646 -82
- data/vendor/assets/javascripts/RGraph.gauge.js +1773 -89
- data/vendor/assets/javascripts/RGraph.hbar.js +3869 -159
- data/vendor/assets/javascripts/RGraph.horseshoe.js +970 -0
- data/vendor/assets/javascripts/RGraph.hprogress.js +1829 -81
- data/vendor/assets/javascripts/RGraph.line.js +5293 -244
- data/vendor/assets/javascripts/RGraph.meter.js +1570 -77
- data/vendor/assets/javascripts/RGraph.modaldialog.js +300 -19
- data/vendor/assets/javascripts/RGraph.odo.js +1553 -68
- data/vendor/assets/javascripts/RGraph.pie.js +3273 -129
- data/vendor/assets/javascripts/RGraph.radar.js +2333 -108
- data/vendor/assets/javascripts/RGraph.rose.js +2685 -114
- data/vendor/assets/javascripts/RGraph.rscatter.js +1920 -80
- data/vendor/assets/javascripts/RGraph.scatter.js +4215 -171
- data/vendor/assets/javascripts/RGraph.segmented.js +1006 -0
- data/vendor/assets/javascripts/RGraph.semicircularprogress.js +1980 -59
- data/vendor/assets/javascripts/RGraph.svg.activity.js +1696 -0
- data/vendor/assets/javascripts/RGraph.svg.bar.js +2575 -77
- data/vendor/assets/javascripts/RGraph.svg.bipolar.js +3533 -106
- data/vendor/assets/javascripts/RGraph.svg.common.ajax.js +240 -21
- data/vendor/assets/javascripts/RGraph.svg.common.core.js +7105 -299
- data/vendor/assets/javascripts/RGraph.svg.common.csv.js +408 -28
- data/vendor/assets/javascripts/RGraph.svg.common.fx.js +1291 -68
- data/vendor/assets/javascripts/RGraph.svg.common.key.js +451 -20
- data/vendor/assets/javascripts/RGraph.svg.common.sheets.js +543 -31
- data/vendor/assets/javascripts/RGraph.svg.common.table.js +391 -0
- data/vendor/assets/javascripts/RGraph.svg.common.tooltips.js +1072 -23
- data/vendor/assets/javascripts/RGraph.svg.funnel.js +1151 -32
- data/vendor/assets/javascripts/RGraph.svg.gauge.js +1429 -34
- data/vendor/assets/javascripts/RGraph.svg.hbar.js +2692 -65
- data/vendor/assets/javascripts/RGraph.svg.horseshoe.js +969 -0
- data/vendor/assets/javascripts/RGraph.svg.line.js +2855 -86
- data/vendor/assets/javascripts/RGraph.svg.pie.js +1630 -58
- data/vendor/assets/javascripts/RGraph.svg.radar.js +1772 -58
- data/vendor/assets/javascripts/RGraph.svg.rose.js +2419 -83
- data/vendor/assets/javascripts/RGraph.svg.scatter.js +2280 -65
- data/vendor/assets/javascripts/RGraph.svg.segmented.js +930 -0
- data/vendor/assets/javascripts/RGraph.svg.semicircularprogress.js +1612 -29
- data/vendor/assets/javascripts/RGraph.svg.waterfall.js +1525 -50
- data/vendor/assets/javascripts/RGraph.thermometer.js +1411 -64
- data/vendor/assets/javascripts/RGraph.vprogress.js +1915 -81
- data/vendor/assets/javascripts/RGraph.waterfall.js +1896 -89
- data/vendor/assets/javascripts/financial-data.js +1067 -0
- metadata +37 -16
- data/.travis.yml +0 -11
- data/vendor/assets/javascripts/RGraph.common.deprecated.js +0 -35
- data/vendor/assets/javascripts/RGraph.common.resizing.js +0 -38
- data/vendor/assets/javascripts/RGraph.common.zoom.js +0 -15
- data/vendor/assets/javascripts/RGraph.cornergauge.js +0 -71
@@ -1,60 +1,1150 @@
|
|
1
|
+
'version:2023-09-16 (6.14)';
|
2
|
+
//
|
3
|
+
// o--------------------------------------------------------------------------------o
|
4
|
+
// | This file is part of the RGraph package - you can learn more at: |
|
5
|
+
// | |
|
6
|
+
// | https://www.rgraph.net |
|
7
|
+
// | |
|
8
|
+
// | RGraph is licensed under the Open Source MIT license. That means that it's |
|
9
|
+
// | totally free to use and there are no restrictions on what you can do with it! |
|
10
|
+
// o--------------------------------------------------------------------------------o
|
1
11
|
|
2
|
-
RGraph=window.RGraph||{isRGraph:true};
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
this.
|
19
|
-
this.
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
this.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
12
|
+
RGraph = window.RGraph || {isrgraph:true,isRGraph:true,rgraph:true};
|
13
|
+
|
14
|
+
//
|
15
|
+
// The Fuel widget constructor
|
16
|
+
//
|
17
|
+
RGraph.Fuel = function (conf)
|
18
|
+
{
|
19
|
+
var id = conf.id,
|
20
|
+
canvas = document.getElementById(id),
|
21
|
+
min = conf.min,
|
22
|
+
max = conf.max,
|
23
|
+
value = conf.value;
|
24
|
+
|
25
|
+
// Get the canvas and context objects
|
26
|
+
this.id = id;
|
27
|
+
this.canvas = canvas;
|
28
|
+
this.context = this.canvas.getContext ? this.canvas.getContext("2d", {alpha: (typeof id === 'object' && id.alpha === false) ? false : true}) : null;
|
29
|
+
this.canvas.__object__ = this;
|
30
|
+
this.type = 'fuel';
|
31
|
+
this.isRGraph = true;
|
32
|
+
this.isrgraph = true;
|
33
|
+
this.rgraph = true;
|
34
|
+
this.min = RGraph.stringsToNumbers(min);
|
35
|
+
this.max = RGraph.stringsToNumbers(max);
|
36
|
+
this.value = RGraph.stringsToNumbers(value);
|
37
|
+
this.angles = {};
|
38
|
+
this.currentValue = null;
|
39
|
+
this.uid = RGraph.createUID();
|
40
|
+
this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.createUID();
|
41
|
+
this.coordsText = [];
|
42
|
+
this.original_colors = [];
|
43
|
+
this.firstDraw = true; // After the first draw this will be false
|
44
|
+
this.stopAnimationRequested = false;// Used to control the animations
|
45
|
+
|
46
|
+
// Check for support
|
47
|
+
if (!this.canvas) {
|
48
|
+
alert('[FUEL] No canvas support');
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
|
52
|
+
//
|
53
|
+
// The funnel charts properties
|
54
|
+
//
|
55
|
+
this.properties =
|
56
|
+
{
|
57
|
+
centerx: null,
|
58
|
+
centery: null,
|
59
|
+
radius: null,
|
60
|
+
|
61
|
+
colors: ['red'],
|
62
|
+
|
63
|
+
needleColor: 'red',
|
64
|
+
needleRadiusOffset: 45,
|
65
|
+
|
66
|
+
marginLeft: 5,
|
67
|
+
marginRight: 5,
|
68
|
+
marginTop: 5,
|
69
|
+
marginBottom: 5,
|
70
|
+
|
71
|
+
textSize: 12,
|
72
|
+
textColor: 'black', // Does not support gradients
|
73
|
+
textFont: 'Arial, Verdana, sans-serif',
|
74
|
+
textBold: false,
|
75
|
+
textItalic: false,
|
76
|
+
textAccessible: false,
|
77
|
+
textAccessibleOverflow: 'visible',
|
78
|
+
textAccessiblePointerevents: false,
|
79
|
+
text: null,
|
80
|
+
|
81
|
+
contextmenu: null,
|
82
|
+
|
83
|
+
annotatable: false,
|
84
|
+
annotatableColor: 'black',
|
85
|
+
|
86
|
+
adjustable: false,
|
87
|
+
|
88
|
+
resizable: false,
|
89
|
+
resizableHandleBackground: null,
|
90
|
+
|
91
|
+
icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAfCAYAAAD0ma06AAAEGElEQVRIS7VXSyhtYRT+jnfe5FEMjAwUBiQGHikzRWIkkgy8YyDK+xnJK5JCeZSUGKBMiAyYkMxMJAMpSfJ+2/d8695/33NunSPnHqt2Z5+91/9/' + '/' + '/et9a/1b8Pn56dmMBhg/IWDgwNoNzc38PHxkXtN0+Tiexp9eH18fIDj1Bj63N/fw8vLS/wsmcHoqKmXT09PuL29RVFREU5OTvTJ6UIAgioQ+vLe09MTb29v8PX1RWBgICYnJ+XXIqDRWXN0dJT3nIDsWlpadP+lpSWZlD4KmL/8/' + '/7+Ls/S09N1/7y8PISHh+sK/QssDJWcHEyGCnB1dRUDAwPIzMzUx5GpAnZ1dcXy8jK2trbM5j06OsLc3JzISx8q4OzsLOOsAq6treHg4AAeHh4WJbq7u0Nzc7P+PiYmBnt7ezg9PcXExAQCAgLg5OSEx8dHuLu7Wwfc3t7G/v6+yEcjO8rIROGKaWdnZ+jr6zMDjI6OxvT0tDzr6uqS2KtksspwZ2cHjY2NuqSUhnHmilUCraysmElaWloKJpQCjI2NRX5+Pl5eXr6WlCv08/MTEMVOZDH+Zzw4CdlfX1/rDHt7ezE1NQXGkcYEKi4ulkVKYlpLGouBs/JiaGgIZL25uSlecXFxohAz/ccAz8/P4e/vj7q6Ojw8PMje5DNRy94MQ0JCUFtbK2wqKipE+sHBQbi4uPwMQ86ak5ODxMREVFdXIywsDCUlJRJDXnZlmJqaip6eHuTm5kqikGlycjIyMjL+ZrY9JSUgMzQiIgINDQ2ypaqqqkCZWXHsnjQEHB8fR0pKigAxabq7uyWOlJNxtLukTJDs7GxUVlZKDNl5oqKi8Pr6+jOAIyMjiI+Pl5JGQG4F1Qy+LN7f3fiUdGZmBsHBwRgbG8Pw8LD01ba2NmlX0rTtnTQLCwvSjEdHR3FxcSExLCwsRGRkpBR9vePzeMDyw3bT1NT0XXLiT4a7u7s4Pj4GGzd7K8GCgoKEsRR8I4Cm6hwHXV5eiv62GAE5npMTmFuBTCkzmzT7qs5Q9TlW/o6ODlvwhCHPM5SVPZIxYzNeXFxEa2srvL29YTC2GI3aMm3Zeq6urv4LMC0tDRsbG1K8k5KS9DgS0IwhKVFjSsJA22r9/f0oKCgQdvPz83JEmZ2dlcpD9maSshow0KZnlO8Csx9yK3BLKCMJPpf2xGMigdi9WXooaWdn53dxdP+amhrZh4eHh1hfX5cTW319vZyBnp+ffzNkBWBmhYaGysB/j322oCckJCArK0uGMlsJ5ubmBoPxRiMzFlomjr2MGdne3i5ANILRJEtJt6ysTG8h9gDl4am8vFwSUWron1O9LulXIOqk9pWftfdSS40yyj5Uh101wPRryuR7R1ZMX/U1pfy5IF40xcgUnGAc9wsGYxsFhy87kwAAAABJRU5ErkJggg==',
|
92
|
+
iconRedraw: true,
|
93
|
+
|
94
|
+
backgroundImageStretch: false,
|
95
|
+
backgroundImageX: null,
|
96
|
+
backgroundImageY: null,
|
97
|
+
backgroundImageW: null,
|
98
|
+
backgroundImageH: null,
|
99
|
+
backgroundImagealign: null,
|
100
|
+
|
101
|
+
labelsFull: 'F',
|
102
|
+
labelsFullOffsetx: 0,
|
103
|
+
labelsFullOffsety: 0,
|
104
|
+
labelsFullOffsetRadius: 0,
|
105
|
+
labelsEmpty: 'E',
|
106
|
+
labelsEmptyOffsetx: 0,
|
107
|
+
labelsEmptyOffsety: 0,
|
108
|
+
labelsEmptyOffsetRadius: 0,
|
109
|
+
labelsFont: null,
|
110
|
+
labelsSize: null,
|
111
|
+
labelsColor: null,
|
112
|
+
labelsBold: null,
|
113
|
+
labelsItalic: null,
|
114
|
+
|
115
|
+
scaleVisible: false,
|
116
|
+
scaleDecimals: 0,
|
117
|
+
scaleUnitsPre: '',
|
118
|
+
scaleUnitsPost: '',
|
119
|
+
scalePoint: '.',
|
120
|
+
scaleThousand: ',',
|
121
|
+
scaleLabelsCount: 5,
|
122
|
+
|
123
|
+
clearto: 'rgba(0,0,0,0)'
|
124
|
+
}
|
125
|
+
|
126
|
+
//
|
127
|
+
// Bounds checking - if the value is outside the scale
|
128
|
+
//
|
129
|
+
if (this.value > this.max) this.value = this.max;
|
130
|
+
if (this.value < this.min) this.value = this.min;
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
// Easy access to properties and the path function
|
136
|
+
var properties = this.properties;
|
137
|
+
this.path = RGraph.pathObjectFunction;
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
//
|
142
|
+
// "Decorate" the object with the generic effects if the effects library has been included
|
143
|
+
//
|
144
|
+
if (RGraph.Effects && typeof RGraph.Effects.decorate === 'function') {
|
145
|
+
RGraph.Effects.decorate(this);
|
146
|
+
}
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
// Add the responsive method. This method resides in the common file.
|
151
|
+
this.responsive = RGraph.responsive;
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
//
|
161
|
+
// A setter
|
162
|
+
//
|
163
|
+
// @param name string The name of the property to set
|
164
|
+
// @param value mixed The value of the property
|
165
|
+
//
|
166
|
+
this.set = function (name)
|
167
|
+
{
|
168
|
+
var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
|
169
|
+
|
170
|
+
// the number of arguments is only one and it's an
|
171
|
+
// object - parse it for configuration data and return.
|
172
|
+
if (arguments.length === 1 && typeof arguments[0] === 'object') {
|
173
|
+
for (i in arguments[0]) {
|
174
|
+
if (typeof i === 'string') {
|
175
|
+
this.set(i, arguments[0][i]);
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
return this;
|
180
|
+
}
|
181
|
+
|
182
|
+
properties[name] = value;
|
183
|
+
|
184
|
+
return this;
|
185
|
+
};
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
//
|
195
|
+
// A getter
|
196
|
+
//
|
197
|
+
// @param name string The name of the property to get
|
198
|
+
//
|
199
|
+
this.get = function (name)
|
200
|
+
{
|
201
|
+
return properties[name];
|
202
|
+
};
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
//
|
212
|
+
// The function you call to draw the bar chart
|
213
|
+
//
|
214
|
+
this.draw = function ()
|
215
|
+
{
|
216
|
+
//
|
217
|
+
// Fire the onbeforedraw event
|
218
|
+
//
|
219
|
+
RGraph.fireCustomEvent(this, 'onbeforedraw');
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
// Translate half a pixel for antialiasing purposes - but only if it hasn't been
|
225
|
+
// done already
|
226
|
+
//
|
227
|
+
// MUST be the first thing done!
|
228
|
+
//
|
229
|
+
if (!this.canvas.__rgraph_aa_translated__) {
|
230
|
+
this.context.translate(0.5,0.5);
|
231
|
+
|
232
|
+
this.canvas.__rgraph_aa_translated__ = true;
|
233
|
+
}
|
234
|
+
|
235
|
+
|
236
|
+
//
|
237
|
+
// Set the current value
|
238
|
+
//
|
239
|
+
this.currentValue = this.value;
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
//
|
244
|
+
// Make the margins easy ro access
|
245
|
+
//
|
246
|
+
this.marginLeft = properties.marginLeft;
|
247
|
+
this.marginRight = properties.marginRight;
|
248
|
+
this.marginTop = properties.marginTop;
|
249
|
+
this.marginBottom = properties.marginBottom;
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
//
|
254
|
+
// Get the center X and Y of the chart. This is the center of the needle bulb
|
255
|
+
//
|
256
|
+
this.centerx = ((this.canvas.width - this.marginLeft - this.marginRight) / 2) + this.marginLeft;
|
257
|
+
this.centery = this.canvas.height - 20 - this.marginBottom
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
//
|
262
|
+
// Work out the radius of the chart
|
263
|
+
//
|
264
|
+
this.radius = this.canvas.height - this.marginTop - this.marginBottom - 20;
|
265
|
+
|
266
|
+
//
|
267
|
+
// Stop this growing uncntrollably
|
268
|
+
//
|
269
|
+
this.coordsText = [];
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
//
|
274
|
+
// You can now specify chart.centerx, chart.centery and chart.radius
|
275
|
+
//
|
276
|
+
if (typeof properties.centerx == 'number') this.centerx = properties.centerx;
|
277
|
+
if (typeof properties.centery == 'number') this.centery = properties.centery;
|
278
|
+
if (typeof properties.radius == 'number') this.radius = properties.radius;
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
//
|
284
|
+
// Parse the colors. This allows for simple gradient syntax
|
285
|
+
//
|
286
|
+
if (!this.colorsParsed) {
|
287
|
+
this.parseColors();
|
288
|
+
|
289
|
+
// Don't want to do this again
|
290
|
+
this.colorsParsed = true;
|
291
|
+
}
|
292
|
+
|
293
|
+
|
294
|
+
//
|
295
|
+
// The start and end angles of the chart
|
296
|
+
//
|
297
|
+
this.angles.start = (RGraph.PI + RGraph.HALFPI) - 0.5;
|
298
|
+
this.angles.end = (RGraph.PI + RGraph.HALFPI) + 0.5;
|
299
|
+
this.angles.needle = this.getAngle(this.value);
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
//
|
304
|
+
// Draw the labels on the chart
|
305
|
+
//
|
306
|
+
this.drawLabels();
|
307
|
+
|
308
|
+
|
309
|
+
//
|
310
|
+
// Draw the fuel guage
|
311
|
+
//
|
312
|
+
this.drawChart();
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
//
|
319
|
+
// Setup the context menu if required
|
320
|
+
//
|
321
|
+
if (properties.contextmenu) {
|
322
|
+
RGraph.showContext(this);
|
323
|
+
}
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
//
|
329
|
+
// Add custom text thats specified
|
330
|
+
//
|
331
|
+
RGraph.addCustomText(this);
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
//
|
339
|
+
// This installs the event listeners
|
340
|
+
//
|
341
|
+
RGraph.installEventListeners(this);
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
//
|
346
|
+
// Fire the onfirstdraw event
|
347
|
+
//
|
348
|
+
if (this.firstDraw) {
|
349
|
+
this.firstDraw = false;
|
350
|
+
RGraph.fireCustomEvent(this, 'onfirstdraw');
|
351
|
+
this.firstDrawFunc();
|
352
|
+
}
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
//
|
357
|
+
// Fire the RGraph draw event
|
358
|
+
//
|
359
|
+
RGraph.fireCustomEvent(this, 'ondraw');
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
//
|
370
|
+
// Install any inline responsive configuration. This
|
371
|
+
// should be last in the draw function - even after
|
372
|
+
// the draw events.
|
373
|
+
//
|
374
|
+
RGraph.installInlineResponsive(this);
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
return this;
|
387
|
+
};
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
//
|
397
|
+
// Used in chaining. Runs a function there and then - not waiting for
|
398
|
+
// the events to fire (eg the onbeforedraw event)
|
399
|
+
//
|
400
|
+
// @param function func The function to execute
|
401
|
+
//
|
402
|
+
this.exec = function (func)
|
403
|
+
{
|
404
|
+
func(this);
|
405
|
+
|
406
|
+
return this;
|
407
|
+
};
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
//
|
417
|
+
// This function actually draws the chart
|
418
|
+
//
|
419
|
+
this.drawChart = function ()
|
420
|
+
{
|
421
|
+
//
|
422
|
+
// Draw the "Scale"
|
423
|
+
//
|
424
|
+
this.drawScale();
|
425
|
+
|
426
|
+
// Place the icon on the canvas
|
427
|
+
this.drawIcon();
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
//
|
432
|
+
// Draw the needle
|
433
|
+
//
|
434
|
+
this.drawNeedle();
|
435
|
+
};
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
//
|
445
|
+
// Draws the labels
|
446
|
+
//
|
447
|
+
this.drawLabels = function ()
|
448
|
+
{
|
449
|
+
if (!properties.scaleVisible) {
|
450
|
+
|
451
|
+
var radius = (this.radius - 20);
|
452
|
+
|
453
|
+
this.context.fillStyle = properties.textColor;
|
454
|
+
|
455
|
+
// Draw the left label
|
456
|
+
var y = this.centery - Math.sin(this.angles.start - RGraph.PI) * (this.radius - 17 + properties.labelsEmptyOffsetRadius);
|
457
|
+
var x = this.centerx - Math.cos(this.angles.start - RGraph.PI) * (this.radius - 17 + properties.labelsEmptyOffsetRadius);
|
458
|
+
|
459
|
+
// Get the text configuration
|
460
|
+
var textConf = RGraph.getTextConf({
|
461
|
+
object: this,
|
462
|
+
prefix: 'labels'
|
463
|
+
});
|
464
|
+
|
465
|
+
var ret = RGraph.text({
|
466
|
+
|
467
|
+
object: this,
|
468
|
+
|
469
|
+
font: textConf.font,
|
470
|
+
size: textConf.size,
|
471
|
+
color: textConf.color,
|
472
|
+
bold: textConf.bold,
|
473
|
+
italic: textConf.italic,
|
474
|
+
|
475
|
+
x: x + properties.labelsEmptyOffsetx,
|
476
|
+
y: y + properties.labelsEmptyOffsety,
|
477
|
+
|
478
|
+
text: properties.labelsEmpty,
|
479
|
+
|
480
|
+
halign: 'left',
|
481
|
+
valign: 'top',
|
482
|
+
|
483
|
+
tag: 'labels',
|
484
|
+
cssClass: RGraph.getLabelsCSSClassName({
|
485
|
+
object: this,
|
486
|
+
name: 'labelsClass',
|
487
|
+
index: 0
|
488
|
+
})
|
489
|
+
});
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
// Draw the right label
|
504
|
+
var y = this.centery - Math.sin(this.angles.start - RGraph.PI) * (this.radius - 17 + properties.labelsFullOffsetRadius);
|
505
|
+
var x = this.centerx + Math.cos(this.angles.start - RGraph.PI) * (this.radius - 17 + properties.labelsFullOffsetRadius);
|
506
|
+
var ret = RGraph.text({
|
507
|
+
|
508
|
+
object: this,
|
509
|
+
|
510
|
+
font: textConf.font,
|
511
|
+
size: textConf.size,
|
512
|
+
color: textConf.color,
|
513
|
+
bold: textConf.bold,
|
514
|
+
italic: textConf.italic,
|
515
|
+
|
516
|
+
x: x + properties.labelsFullOffsetx,
|
517
|
+
y: y + properties.labelsFullOffsety,
|
518
|
+
|
519
|
+
text: properties.labelsFull,
|
520
|
+
|
521
|
+
halign: 'right',
|
522
|
+
valign: 'top',
|
523
|
+
|
524
|
+
tag: 'labels',
|
525
|
+
cssClass: RGraph.getLabelsCSSClassName({
|
526
|
+
object: this,
|
527
|
+
name: 'labelsClass',
|
528
|
+
index: 1
|
529
|
+
})
|
530
|
+
});
|
531
|
+
}
|
532
|
+
|
533
|
+
// Add any CSS class to the text
|
534
|
+
var className = '';
|
535
|
+
|
536
|
+
if (typeof properties.labelsClass === 'string') {
|
537
|
+
className = properties.labelsClass;
|
538
|
+
} else if (typeof properties.labelsClass === 'object' && typeof properties.labelsClass[1] === 'string') {
|
539
|
+
className = properties.labelsClass[1];
|
540
|
+
}
|
541
|
+
|
542
|
+
if (className && ret.node.className.indexOf(className) === -1) {
|
543
|
+
ret.node.className += ' ' + className;
|
544
|
+
}
|
545
|
+
};
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
//
|
555
|
+
// Draws the needle
|
556
|
+
//
|
557
|
+
this.drawNeedle = function ()
|
558
|
+
{
|
559
|
+
// Draw the needle
|
560
|
+
this.context.beginPath();
|
561
|
+
this.context.lineWidth = 5;
|
562
|
+
this.context.lineCap = 'round';
|
563
|
+
this.context.strokeStyle = properties.needleColor;
|
564
|
+
|
565
|
+
//
|
566
|
+
// The angle for the needle
|
567
|
+
//
|
568
|
+
var angle = this.angles.needle;
|
569
|
+
|
570
|
+
this.context.arc(this.centerx, this.centery, this.radius - properties.needleRadiusOffset, angle, angle + 0.0001, false);
|
571
|
+
this.context.lineTo(this.centerx, this.centery);
|
572
|
+
this.context.stroke();
|
573
|
+
|
574
|
+
this.context.lineWidth = 1;
|
575
|
+
|
576
|
+
// Create the gradient for the bulb
|
577
|
+
var cx = this.centerx + 10;
|
578
|
+
var cy = this.centery - 10
|
579
|
+
|
580
|
+
var grad = this.context.createRadialGradient(cx, cy, 35, cx, cy, 0);
|
581
|
+
grad.addColorStop(0, 'black');
|
582
|
+
grad.addColorStop(1, '#eee');
|
583
|
+
|
584
|
+
if (navigator.userAgent.indexOf('Firefox/6.0') > 0) {
|
585
|
+
grad = this.context.createLinearGradient(cx + 10, cy - 10, cx - 10, cy + 10);
|
586
|
+
grad.addColorStop(1, '#666');
|
587
|
+
grad.addColorStop(0.5, '#ccc');
|
588
|
+
}
|
589
|
+
|
590
|
+
// Draw the bulb
|
591
|
+
this.context.beginPath();
|
592
|
+
this.context.fillStyle = grad;
|
593
|
+
this.context.moveTo(this.centerx, this.centery);
|
594
|
+
this.context.arc(this.centerx, this.centery, 20, 0, RGraph.TWOPI, 0);
|
595
|
+
this.context.fill();
|
596
|
+
};
|
597
|
+
|
598
|
+
|
599
|
+
|
600
|
+
|
601
|
+
|
602
|
+
|
603
|
+
|
604
|
+
|
605
|
+
//
|
606
|
+
// Draws the "scale"
|
607
|
+
//
|
608
|
+
this.drawScale = function ()
|
609
|
+
{
|
610
|
+
var a, x, y;
|
611
|
+
|
612
|
+
//First draw the fill background
|
613
|
+
this.context.beginPath();
|
614
|
+
this.context.strokeStyle = 'black';
|
615
|
+
this.context.fillStyle = 'white';
|
616
|
+
this.context.arc(this.centerx, this.centery, this.radius, this.angles.start, this.angles.end, false);
|
617
|
+
this.context.arc(this.centerx, this.centery, this.radius - 10, this.angles.end, this.angles.start, true);
|
618
|
+
this.context.closePath();
|
619
|
+
this.context.stroke();
|
620
|
+
this.context.fill();
|
621
|
+
|
622
|
+
//First draw the fill itself
|
623
|
+
var start = this.angles.start;
|
624
|
+
var end = this.angles.needle;
|
625
|
+
|
626
|
+
this.context.beginPath();
|
627
|
+
this.context.fillStyle = properties.colors[0];
|
628
|
+
this.context.arc(this.centerx, this.centery, this.radius, start, end, false);
|
629
|
+
this.context.arc(this.centerx, this.centery, this.radius - 10, end, start, true);
|
630
|
+
this.context.closePath();
|
631
|
+
//this.context.stroke();
|
632
|
+
this.context.fill();
|
633
|
+
|
634
|
+
// This draws the tickmarks
|
635
|
+
for (a = this.angles.start; a<=this.angles.end + 0.01; a+=((this.angles.end - this.angles.start) / 5)) {
|
636
|
+
this.context.beginPath();
|
637
|
+
this.context.arc(this.centerx, this.centery, this.radius - 10, a, a + 0.0001, false);
|
638
|
+
this.context.arc(this.centerx, this.centery, this.radius - 15, a + 0.0001, a, true);
|
639
|
+
this.context.stroke();
|
640
|
+
}
|
641
|
+
|
642
|
+
//
|
643
|
+
// If chart.scale.visible is specified draw the textual scale
|
644
|
+
//
|
645
|
+
if (properties.scaleVisible) {
|
646
|
+
|
647
|
+
this.context.fillStyle = properties.textColor;
|
648
|
+
|
649
|
+
// The labels
|
650
|
+
var numLabels = properties.scaleLabelsCount;
|
651
|
+
var decimals = properties.scaleDecimals;
|
652
|
+
var units_post = properties.scaleUnitsPost;
|
653
|
+
var units_pre = properties.scaleUnitsPre;
|
654
|
+
var font = properties.textFont;
|
655
|
+
var size = properties.textSize;
|
656
|
+
var color = properties.textColor;
|
657
|
+
var bold = properties.textBold;
|
658
|
+
var italic = properties.textItalic;
|
659
|
+
|
660
|
+
for (var i=0; i<=numLabels; ++i) {
|
661
|
+
|
662
|
+
a = ((this.angles.end - this.angles.start) * (i/numLabels)) + this.angles.start;
|
663
|
+
y = this.centery - Math.sin(a - RGraph.PI) * (this.radius - 17);
|
664
|
+
x = this.centerx - Math.cos(a - RGraph.PI) * (this.radius - 17);
|
665
|
+
|
666
|
+
|
667
|
+
// Get the text configuration
|
668
|
+
var textConf = RGraph.getTextConf({
|
669
|
+
object: this,
|
670
|
+
prefix: 'labels'
|
671
|
+
});
|
672
|
+
|
673
|
+
RGraph.text({
|
674
|
+
|
675
|
+
object: this,
|
676
|
+
|
677
|
+
font: textConf.font,
|
678
|
+
size: textConf.size,
|
679
|
+
color: textConf.color,
|
680
|
+
bold: textConf.bold,
|
681
|
+
italic: textConf.italic,
|
682
|
+
|
683
|
+
x: x,
|
684
|
+
y: y,
|
685
|
+
text: RGraph.numberFormat({
|
686
|
+
object: this,
|
687
|
+
number: (this.min + ((this.max - this.min) * (i/numLabels))).toFixed(decimals),
|
688
|
+
unitspre: units_pre,
|
689
|
+
unitspost: units_post,
|
690
|
+
point: properties.scalePoint,
|
691
|
+
thousand: properties.scaleThousand
|
692
|
+
}),
|
693
|
+
halign: 'center',
|
694
|
+
valign: 'top',
|
695
|
+
tag: 'scale'
|
696
|
+
});
|
697
|
+
}
|
698
|
+
}
|
699
|
+
};
|
700
|
+
|
701
|
+
|
702
|
+
|
703
|
+
|
704
|
+
|
705
|
+
|
706
|
+
|
707
|
+
|
708
|
+
//
|
709
|
+
// A placeholder function that is here to prevent errors
|
710
|
+
//
|
711
|
+
this.getShape = function (e) {};
|
712
|
+
|
713
|
+
|
714
|
+
|
715
|
+
|
716
|
+
|
717
|
+
|
718
|
+
|
719
|
+
|
720
|
+
//
|
721
|
+
// This function returns the pertinent value based on a click
|
722
|
+
//
|
723
|
+
// @param object e An event object
|
724
|
+
// @return number The relevant value at the point of click
|
725
|
+
//
|
726
|
+
this.getValue = function (e)
|
727
|
+
{
|
728
|
+
var mouseXY = RGraph.getMouseXY(e);
|
729
|
+
var angle = RGraph.getAngleByXY(this.centerx, this.centery, mouseXY[0], mouseXY[1]);
|
730
|
+
|
731
|
+
//
|
732
|
+
// Boundary checking
|
733
|
+
//
|
734
|
+
if (angle >= this.angles.end) {
|
735
|
+
return this.max;
|
736
|
+
} else if (angle <= this.angles.start) {
|
737
|
+
return this.min;
|
738
|
+
}
|
739
|
+
|
740
|
+
var value = (angle - this.angles.start) / (this.angles.end - this.angles.start);
|
741
|
+
value = value * (this.max - this.min);
|
742
|
+
value = value + this.min;
|
743
|
+
|
744
|
+
return value;
|
745
|
+
};
|
746
|
+
|
747
|
+
|
748
|
+
|
749
|
+
|
750
|
+
|
751
|
+
|
752
|
+
|
753
|
+
|
754
|
+
//
|
755
|
+
// The getObjectByXY() worker method. Don't call this call:
|
756
|
+
//
|
757
|
+
// RGraph.ObjectRegistry.getObjectByXY(e)
|
758
|
+
//
|
759
|
+
// @param object e The event object
|
760
|
+
//
|
761
|
+
this.getObjectByXY = function (e)
|
762
|
+
{
|
763
|
+
var mouseXY = RGraph.getMouseXY(e);
|
764
|
+
var angle = RGraph.getAngleByXY(this.centerx, this.centery, mouseXY[0], mouseXY[1]);
|
765
|
+
var accuracy = 15;
|
766
|
+
|
767
|
+
var leftMin = this.centerx - this.radius;
|
768
|
+
var rightMax = this.centerx + this.radius;
|
769
|
+
var topMin = this.centery - this.radius;
|
770
|
+
var bottomMax = this.centery + this.radius;
|
771
|
+
|
772
|
+
if (
|
773
|
+
mouseXY[0] > leftMin
|
774
|
+
&& mouseXY[0] < rightMax
|
775
|
+
&& mouseXY[1] > topMin
|
776
|
+
&& mouseXY[1] < bottomMax
|
777
|
+
) {
|
778
|
+
|
779
|
+
return this;
|
780
|
+
}
|
781
|
+
};
|
782
|
+
|
783
|
+
|
784
|
+
|
785
|
+
|
786
|
+
|
787
|
+
|
788
|
+
|
789
|
+
|
790
|
+
//
|
791
|
+
// Draws the icon
|
792
|
+
//
|
793
|
+
this.drawIcon = function ()
|
794
|
+
{
|
795
|
+
if (!this.__icon__ || !this.__icon__.__loaded__) {
|
796
|
+
var img = new Image();
|
797
|
+
img.src = properties.icon;
|
798
|
+
img.__object__ = this;
|
799
|
+
this.__icon__ = img;
|
800
|
+
|
801
|
+
img.onload = function (e)
|
802
|
+
{
|
803
|
+
img.__loaded__ = true;
|
804
|
+
var obj = img.__object__;
|
805
|
+
|
806
|
+
obj.context.drawImage(img,obj.centerx - (img.width / 2), obj.centery - obj.radius + 35);
|
807
|
+
|
808
|
+
obj.drawNeedle();
|
809
|
+
|
810
|
+
if (properties.iconRedraw) {
|
811
|
+
obj.set('iconRedraw', false);
|
812
|
+
RGraph.clear(obj.canvas);
|
813
|
+
RGraph.redrawCanvas(obj.canvas);
|
814
|
+
}
|
815
|
+
}
|
816
|
+
} else {
|
817
|
+
var img = this.__icon__;
|
818
|
+
this.context.drawImage(img,this.centerx - (img.width / 2), this.centery - this.radius + 35);
|
819
|
+
}
|
820
|
+
|
821
|
+
this.drawNeedle();
|
822
|
+
};
|
823
|
+
|
824
|
+
|
825
|
+
|
826
|
+
|
827
|
+
|
828
|
+
|
829
|
+
|
830
|
+
|
831
|
+
//
|
832
|
+
// This method handles the adjusting calculation for when the mouse is moved
|
833
|
+
//
|
834
|
+
// @param object e The event object
|
835
|
+
//
|
836
|
+
this.adjusting_mousemove = function (e)
|
837
|
+
{
|
838
|
+
//
|
839
|
+
// Handle adjusting for the Fuel gauge
|
840
|
+
//
|
841
|
+
if (properties.adjustable && RGraph.Registry.get('adjusting') && RGraph.Registry.get('adjusting').uid == this.uid) {
|
842
|
+
this.value = this.getValue(e);
|
843
|
+
RGraph.redrawCanvas(this.canvas);
|
844
|
+
RGraph.fireCustomEvent(this, 'onadjust');
|
845
|
+
}
|
846
|
+
};
|
847
|
+
|
848
|
+
|
849
|
+
|
850
|
+
|
851
|
+
|
852
|
+
|
853
|
+
|
854
|
+
|
855
|
+
//
|
856
|
+
// This method gives you the relevant angle (in radians) that a particular value is
|
857
|
+
//
|
858
|
+
// @param number value The relevant angle
|
859
|
+
//
|
860
|
+
this.getAngle = function (value)
|
861
|
+
{
|
862
|
+
// Range checking
|
863
|
+
if (value < this.min || value > this.max) {
|
864
|
+
return null;
|
865
|
+
}
|
866
|
+
|
867
|
+
var angle = (((value - this.min) / (this.max - this.min)) * (this.angles.end - this.angles.start)) + this.angles.start;
|
868
|
+
|
869
|
+
return angle;
|
870
|
+
};
|
871
|
+
|
872
|
+
|
873
|
+
|
874
|
+
|
875
|
+
|
876
|
+
|
877
|
+
|
878
|
+
|
879
|
+
//
|
880
|
+
// This allows for easy specification of gradients
|
881
|
+
//
|
882
|
+
this.parseColors = function ()
|
883
|
+
{
|
884
|
+
// Save the original colors so that they can be restored when the canvas is reset
|
885
|
+
if (this.original_colors.length === 0) {
|
886
|
+
this.original_colors.colors = RGraph.arrayClone(properties.colors);
|
887
|
+
this.original_colors.needleColor = RGraph.arrayClone(properties.needleColor);
|
888
|
+
}
|
889
|
+
|
890
|
+
var colors = properties.colors;
|
891
|
+
|
892
|
+
for (var i=0; i<colors.length; ++i) {
|
893
|
+
colors[i] = this.parseSingleColorForLinearGradient(colors[i]);
|
894
|
+
}
|
895
|
+
|
896
|
+
properties.needleColor = this.parseSingleColorForRadialGradient(properties.needleColor);
|
897
|
+
};
|
898
|
+
|
899
|
+
|
900
|
+
|
901
|
+
|
902
|
+
|
903
|
+
|
904
|
+
|
905
|
+
|
906
|
+
//
|
907
|
+
// Use this function to reset the object to the post-constructor state. Eg reset colors if
|
908
|
+
// need be etc
|
909
|
+
//
|
910
|
+
this.reset = function ()
|
911
|
+
{
|
912
|
+
};
|
913
|
+
|
914
|
+
|
915
|
+
|
916
|
+
|
917
|
+
|
918
|
+
|
919
|
+
|
920
|
+
|
921
|
+
//
|
922
|
+
// This parses a single color value
|
923
|
+
//
|
924
|
+
this.parseSingleColorForLinearGradient = function (color)
|
925
|
+
{
|
926
|
+
if (!color || typeof color != 'string') {
|
927
|
+
return color;
|
928
|
+
}
|
929
|
+
|
930
|
+
if (color.match(/^gradient\((.*)\)$/i)) {
|
931
|
+
|
932
|
+
// Allow for JSON gradients
|
933
|
+
if (color.match(/^gradient\(({.*})\)$/i)) {
|
934
|
+
return RGraph.parseJSONGradient({object: this, def: RegExp.$1});
|
935
|
+
}
|
936
|
+
|
937
|
+
var parts = RegExp.$1.split(':');
|
938
|
+
|
939
|
+
// Create the gradient
|
940
|
+
var grad = this.context.createLinearGradient(properties.marginLeft,0,this.canvas.width - properties.marginRight,0);
|
941
|
+
|
942
|
+
var diff = 1 / (parts.length - 1);
|
943
|
+
|
944
|
+
grad.addColorStop(0, RGraph.trim(parts[0]));
|
945
|
+
|
946
|
+
for (var j=1; j<parts.length; ++j) {
|
947
|
+
grad.addColorStop(j * diff, RGraph.trim(parts[j]));
|
948
|
+
}
|
949
|
+
}
|
950
|
+
|
951
|
+
return grad ? grad : color;
|
952
|
+
};
|
953
|
+
|
954
|
+
|
955
|
+
|
956
|
+
|
957
|
+
|
958
|
+
|
959
|
+
|
960
|
+
|
961
|
+
//
|
962
|
+
// This parses a single color value
|
963
|
+
//
|
964
|
+
this.parseSingleColorForRadialGradient = function (color)
|
965
|
+
{
|
966
|
+
if (!color || typeof color != 'string') {
|
967
|
+
return color;
|
968
|
+
}
|
969
|
+
|
970
|
+
if (color.match(/^gradient\((.*)\)$/i)) {
|
971
|
+
|
972
|
+
var parts = RegExp.$1.split(':');
|
973
|
+
|
974
|
+
// Create the gradient
|
975
|
+
var grad = this.context.createRadialGradient(this.centerx, this.centery, 0, this.centerx, this.centery, this.radius);
|
976
|
+
|
977
|
+
var diff = 1 / (parts.length - 1);
|
978
|
+
|
979
|
+
grad.addColorStop(0, RGraph.trim(parts[0]));
|
980
|
+
|
981
|
+
for (var j=1; j<parts.length; ++j) {
|
982
|
+
grad.addColorStop(j * diff, RGraph.trim(parts[j]));
|
983
|
+
}
|
984
|
+
}
|
985
|
+
|
986
|
+
return grad ? grad : color;
|
987
|
+
};
|
988
|
+
|
989
|
+
|
990
|
+
|
991
|
+
|
992
|
+
|
993
|
+
|
994
|
+
|
995
|
+
|
996
|
+
//
|
997
|
+
// Using a function to add events makes it easier to facilitate method chaining
|
998
|
+
//
|
999
|
+
// @param string type The type of even to add
|
1000
|
+
// @param function func
|
1001
|
+
//
|
1002
|
+
this.on = function (type, func)
|
1003
|
+
{
|
1004
|
+
if (type.substr(0,2) !== 'on') {
|
1005
|
+
type = 'on' + type;
|
1006
|
+
}
|
1007
|
+
|
1008
|
+
if (typeof this[type] !== 'function') {
|
1009
|
+
this[type] = func;
|
1010
|
+
} else {
|
1011
|
+
RGraph.addCustomEventListener(this, type, func);
|
1012
|
+
}
|
1013
|
+
|
1014
|
+
return this;
|
1015
|
+
};
|
1016
|
+
|
1017
|
+
|
1018
|
+
|
1019
|
+
|
1020
|
+
|
1021
|
+
|
1022
|
+
|
1023
|
+
|
1024
|
+
//
|
1025
|
+
// This function runs once only
|
1026
|
+
// (put at the end of the file (before any effects))
|
1027
|
+
//
|
1028
|
+
this.firstDrawFunc = function ()
|
1029
|
+
{
|
1030
|
+
};
|
1031
|
+
|
1032
|
+
|
1033
|
+
|
1034
|
+
|
1035
|
+
|
1036
|
+
|
1037
|
+
|
1038
|
+
|
1039
|
+
//
|
1040
|
+
// Grow
|
1041
|
+
//
|
1042
|
+
// The Fuel chart Grow effect gradually increases the values of the Fuel chart
|
1043
|
+
//
|
1044
|
+
// @param object obj The graph object
|
1045
|
+
//
|
1046
|
+
this.grow = function ()
|
1047
|
+
{
|
1048
|
+
// Cancel any stop request if one is pending
|
1049
|
+
this.cancelStopAnimation();
|
1050
|
+
|
1051
|
+
var callback = arguments[1] || function () {};
|
1052
|
+
var opt = arguments[0] || {};
|
1053
|
+
var numFrames = opt.frames || 30;
|
1054
|
+
var frame = 0;
|
1055
|
+
var obj = this;
|
1056
|
+
var origValue = Number(this.currentValue);
|
1057
|
+
|
1058
|
+
if (this.currentValue == null) {
|
1059
|
+
this.currentValue = this.min;
|
1060
|
+
origValue = this.min;
|
1061
|
+
}
|
1062
|
+
|
1063
|
+
var newValue = this.value;
|
1064
|
+
var diff = newValue - origValue;
|
1065
|
+
var step = (diff / numFrames);
|
1066
|
+
var frame = 0;
|
1067
|
+
|
1068
|
+
|
1069
|
+
function iterator ()
|
1070
|
+
{
|
1071
|
+
if (obj.stopAnimationRequested) {
|
1072
|
+
|
1073
|
+
// Reset the flag
|
1074
|
+
obj.stopAnimationRequested = false;
|
1075
|
+
|
1076
|
+
return;
|
1077
|
+
}
|
1078
|
+
|
1079
|
+
frame++;
|
1080
|
+
|
1081
|
+
obj.value = ((frame / numFrames) * diff) + origValue
|
1082
|
+
|
1083
|
+
if (obj.value > obj.max) obj.value = obj.max;
|
1084
|
+
if (obj.value < obj.min) obj.value = obj.min;
|
1085
|
+
|
1086
|
+
RGraph.clear(obj.canvas);
|
1087
|
+
RGraph.redrawCanvas(obj.canvas);
|
1088
|
+
|
1089
|
+
if (frame < numFrames) {
|
1090
|
+
RGraph.Effects.updateCanvas(iterator);
|
1091
|
+
|
1092
|
+
// The callback variable is always function
|
1093
|
+
} else {
|
1094
|
+
callback(obj);
|
1095
|
+
}
|
1096
|
+
}
|
1097
|
+
|
1098
|
+
iterator();
|
1099
|
+
|
1100
|
+
return this;
|
1101
|
+
};
|
1102
|
+
|
1103
|
+
|
1104
|
+
|
1105
|
+
|
1106
|
+
|
1107
|
+
|
1108
|
+
|
1109
|
+
|
1110
|
+
//
|
1111
|
+
// Couple of functions that allow you to control the
|
1112
|
+
// animation effect
|
1113
|
+
//
|
1114
|
+
this.stopAnimation = function ()
|
1115
|
+
{
|
1116
|
+
this.stopAnimationRequested = true;
|
1117
|
+
};
|
1118
|
+
|
1119
|
+
this.cancelStopAnimation = function ()
|
1120
|
+
{
|
1121
|
+
this.stopAnimationRequested = false;
|
1122
|
+
};
|
1123
|
+
|
1124
|
+
|
1125
|
+
|
1126
|
+
|
1127
|
+
|
1128
|
+
|
1129
|
+
|
1130
|
+
|
1131
|
+
//
|
1132
|
+
// Now need to register all chart types. MUST be after the setters/getters are defined
|
1133
|
+
//
|
1134
|
+
// *** MUST BE LAST IN THE CONSTRUCTOR ***
|
1135
|
+
//
|
1136
|
+
RGraph.register(this);
|
1137
|
+
|
1138
|
+
|
1139
|
+
|
1140
|
+
|
1141
|
+
|
1142
|
+
|
1143
|
+
|
1144
|
+
|
1145
|
+
//
|
1146
|
+
// This is the 'end' of the constructor so if the first argument
|
1147
|
+
// contains configuration data - handle that.
|
1148
|
+
//
|
1149
|
+
RGraph.parseObjectStyleConfig(this, conf.options);
|
1150
|
+
};
|