rgraph-rails 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +0 -1
- data/README.md +3 -3
- data/lib/rgraph-rails/version.rb +1 -1
- data/vendor/assets/javascripts/RGraph.bar.js +239 -3764
- data/vendor/assets/javascripts/RGraph.bipolar.js +115 -1986
- data/vendor/assets/javascripts/RGraph.common.annotate.js +35 -399
- data/vendor/assets/javascripts/RGraph.common.context.js +30 -600
- data/vendor/assets/javascripts/RGraph.common.core.js +403 -5187
- data/vendor/assets/javascripts/RGraph.common.csv.js +19 -275
- data/vendor/assets/javascripts/RGraph.common.deprecated.js +35 -454
- data/vendor/assets/javascripts/RGraph.common.dynamic.js +84 -1189
- data/vendor/assets/javascripts/RGraph.common.effects.js +90 -1548
- data/vendor/assets/javascripts/RGraph.common.key.js +54 -755
- data/vendor/assets/javascripts/RGraph.common.resizing.js +37 -567
- data/vendor/assets/javascripts/RGraph.common.sheets.js +29 -356
- data/vendor/assets/javascripts/RGraph.common.tooltips.js +32 -614
- data/vendor/assets/javascripts/RGraph.common.zoom.js +14 -223
- data/vendor/assets/javascripts/RGraph.cornergauge.js +71 -0
- data/vendor/assets/javascripts/RGraph.drawing.background.js +35 -620
- data/vendor/assets/javascripts/RGraph.drawing.circle.js +35 -576
- data/vendor/assets/javascripts/RGraph.drawing.image.js +52 -807
- data/vendor/assets/javascripts/RGraph.drawing.marker1.js +41 -717
- data/vendor/assets/javascripts/RGraph.drawing.marker2.js +37 -668
- data/vendor/assets/javascripts/RGraph.drawing.marker3.js +36 -563
- data/vendor/assets/javascripts/RGraph.drawing.poly.js +40 -608
- data/vendor/assets/javascripts/RGraph.drawing.rect.js +35 -597
- data/vendor/assets/javascripts/RGraph.drawing.text.js +34 -642
- data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +50 -809
- data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +51 -856
- data/vendor/assets/javascripts/RGraph.fuel.js +58 -964
- data/vendor/assets/javascripts/RGraph.funnel.js +55 -984
- data/vendor/assets/javascripts/RGraph.gantt.js +75 -1241
- data/vendor/assets/javascripts/RGraph.gauge.js +87 -1397
- data/vendor/assets/javascripts/RGraph.hbar.js +143 -2376
- data/vendor/assets/javascripts/RGraph.hprogress.js +80 -1397
- data/vendor/assets/javascripts/RGraph.line.js +241 -4162
- data/vendor/assets/javascripts/RGraph.meter.js +74 -1278
- metadata +3 -30
- data/vendor/assets/images/bg.png +0 -0
- data/vendor/assets/images/bullet.png +0 -0
- data/vendor/assets/images/facebook-large.png +0 -0
- data/vendor/assets/images/google-plus-large.png +0 -0
- data/vendor/assets/images/logo.png +0 -0
- data/vendor/assets/images/meter-image-sd-needle.png +0 -0
- data/vendor/assets/images/meter-image-sd.png +0 -0
- data/vendor/assets/images/meter-sketch-needle.png +0 -0
- data/vendor/assets/images/meter-sketch.png +0 -0
- data/vendor/assets/images/odometer-background.png +0 -0
- data/vendor/assets/images/rgraph.jpg +0 -0
- data/vendor/assets/images/title.png +0 -0
- data/vendor/assets/images/twitter-large.png +0 -0
- data/vendor/assets/javascripts/RGraph.modaldialog.js +0 -301
- data/vendor/assets/javascripts/RGraph.odo.js +0 -1265
- data/vendor/assets/javascripts/RGraph.pie.js +0 -2272
- data/vendor/assets/javascripts/RGraph.radar.js +0 -1847
- data/vendor/assets/javascripts/RGraph.rose.js +0 -1877
- data/vendor/assets/javascripts/RGraph.rscatter.js +0 -1425
- data/vendor/assets/javascripts/RGraph.scatter.js +0 -2970
- data/vendor/assets/javascripts/RGraph.semicircularprogress.js +0 -1015
- data/vendor/assets/javascripts/RGraph.thermometer.js +0 -1129
- data/vendor/assets/javascripts/RGraph.vprogress.js +0 -1452
- data/vendor/assets/javascripts/RGraph.waterfall.js +0 -1252
- data/vendor/assets/javascripts/financial-data.js +0 -1067
- data/vendor/assets/stylesheets/ModalDialog.css +0 -90
- data/vendor/assets/stylesheets/animations.css +0 -3347
- data/vendor/assets/stylesheets/website.css +0 -446
@@ -1,1398 +1,81 @@
|
|
1
|
-
// version: 2016-06-04
|
2
|
-
/**
|
3
|
-
* o--------------------------------------------------------------------------------o
|
4
|
-
* | This file is part of the RGraph package - you can learn more at: |
|
5
|
-
* | |
|
6
|
-
* | http://www.rgraph.net |
|
7
|
-
* | |
|
8
|
-
* | RGraph is dual licensed under the Open Source GPL (General Public License) |
|
9
|
-
* | v2.0 license and a commercial license which means that you're not bound by |
|
10
|
-
* | the terms of the GPL. The commercial license is just 99 GBP and you can |
|
11
|
-
* | read about it here: |
|
12
|
-
* | http://www.rgraph.net/license |
|
13
|
-
* o--------------------------------------------------------------------------------o
|
14
|
-
*/
|
15
1
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
'chart.shadow.offsetx': 3,
|
97
|
-
'chart.shadow.offsety': 3,
|
98
|
-
'chart.title': '',
|
99
|
-
'chart.title.background': null,
|
100
|
-
'chart.title.bold': true,
|
101
|
-
'chart.title.font': null,
|
102
|
-
'chart.title.x': null,
|
103
|
-
'chart.title.y': null,
|
104
|
-
'chart.title.halign': null,
|
105
|
-
'chart.title.valign': null,
|
106
|
-
'chart.text.size': 12,
|
107
|
-
'chart.text.color': 'black',
|
108
|
-
'chart.text.font': 'Segoe UI, Arial, Verdana, sans-serif',
|
109
|
-
'chart.text.accessible': true,
|
110
|
-
'chart.text.accessible.overflow': 'visible',
|
111
|
-
'chart.text.accessible.pointerevents': false,
|
112
|
-
'chart.contextmenu': null,
|
113
|
-
'chart.units.pre': '',
|
114
|
-
'chart.units.post': '',
|
115
|
-
'chart.tooltips': null,
|
116
|
-
'chart.tooltips.effect': 'fade',
|
117
|
-
'chart.tooltips.css.class': 'RGraph_tooltip',
|
118
|
-
'chart.tooltips.highlight': true,
|
119
|
-
'chart.tooltips.event': 'onclick',
|
120
|
-
'chart.highlight.stroke': 'rgba(0,0,0,0)',
|
121
|
-
'chart.highlight.fill': 'rgba(255,255,255,0.7)',
|
122
|
-
'chart.annotatable': false,
|
123
|
-
'chart.annotate.color': 'black',
|
124
|
-
'chart.zoom.factor': 1.5,
|
125
|
-
'chart.zoom.fade.in': true,
|
126
|
-
'chart.zoom.fade.out': true,
|
127
|
-
'chart.zoom.hdir': 'right',
|
128
|
-
'chart.zoom.vdir': 'down',
|
129
|
-
'chart.zoom.frames': 25,
|
130
|
-
'chart.zoom.delay': 16.666,
|
131
|
-
'chart.zoom.shadow': true,
|
132
|
-
'chart.zoom.background': true,
|
133
|
-
'chart.arrows': false,
|
134
|
-
'chart.margin': 0,
|
135
|
-
'chart.resizable': false,
|
136
|
-
'chart.resize.handle.adjust':[0,0],
|
137
|
-
'chart.resize.handle.background':null,
|
138
|
-
'chart.labels.specific': null,
|
139
|
-
'chart.labels.count': 10,
|
140
|
-
'chart.labels.offsetx': 0,
|
141
|
-
'chart.labels.offsety': 0,
|
142
|
-
'chart.adjustable': false,
|
143
|
-
'chart.scale.decimals': 0,
|
144
|
-
'chart.scale.point': '.',
|
145
|
-
'chart.scale.thousand': ',',
|
146
|
-
'chart.key': null,
|
147
|
-
'chart.key.background': 'white',
|
148
|
-
'chart.key.position': 'gutter',
|
149
|
-
'chart.key.halign': 'right',
|
150
|
-
'chart.key.shadow': false,
|
151
|
-
'chart.key.shadow.color': '#666',
|
152
|
-
'chart.key.shadow.blur': 3,
|
153
|
-
'chart.key.shadow.offsetx': 2,
|
154
|
-
'chart.key.shadow.offsety': 2,
|
155
|
-
'chart.key.position.gutter.boxed': false,
|
156
|
-
'chart.key.position.x': null,
|
157
|
-
'chart.key.position.y': null,
|
158
|
-
'chart.key.color.shape': 'square',
|
159
|
-
'chart.key.rounded': true,
|
160
|
-
'chart.key.linewidth': 1,
|
161
|
-
'chart.key.colors': null,
|
162
|
-
'chart.key.color.shape': 'square',
|
163
|
-
'chart.key.interactive': false,
|
164
|
-
'chart.key.interactive.highlight.chart.stroke': 'black',
|
165
|
-
'chart.key.interactive.highlight.chart.fill': 'rgba(255,255,255,0.7)',
|
166
|
-
'chart.key.interactive.highlight.label': 'rgba(255,0,0,0.2)',
|
167
|
-
'chart.key.text.color': 'black',
|
168
|
-
'chart.labels.position': 'bottom',
|
169
|
-
'chart.events.mousemove': null,
|
170
|
-
'chart.events.click': null,
|
171
|
-
'chart.border.inner': true,
|
172
|
-
'chart.clearto': 'rgba(0,0,0,0)'
|
173
|
-
}
|
174
|
-
|
175
|
-
|
176
|
-
// Check for support
|
177
|
-
if (!this.canvas) {
|
178
|
-
alert('[HPROGRESS] No canvas support');
|
179
|
-
return;
|
180
|
-
}
|
181
|
-
|
182
|
-
|
183
|
-
/**
|
184
|
-
* Create the dollar objects so that functions can be added to them
|
185
|
-
*/
|
186
|
-
var linear_data = RGraph.array_linearize(value);
|
187
|
-
for (var i=0; i<linear_data.length; ++i) {
|
188
|
-
this['$' + i] = {};
|
189
|
-
}
|
190
|
-
|
191
|
-
|
192
|
-
/**
|
193
|
-
* Translate half a pixel for antialiasing purposes - but only if it hasn't beeen
|
194
|
-
* done already
|
195
|
-
*/
|
196
|
-
if (!this.canvas.__rgraph_aa_translated__) {
|
197
|
-
this.context.translate(0.5,0.5);
|
198
|
-
|
199
|
-
this.canvas.__rgraph_aa_translated__ = true;
|
200
|
-
}
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
// Short variable names
|
205
|
-
var RG = RGraph,
|
206
|
-
ca = this.canvas,
|
207
|
-
co = ca.getContext('2d'),
|
208
|
-
prop = this.properties,
|
209
|
-
pa2 = RG.path2,
|
210
|
-
win = window,
|
211
|
-
doc = document,
|
212
|
-
ma = Math
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
/**
|
217
|
-
* "Decorate" the object with the generic effects if the effects library has been included
|
218
|
-
*/
|
219
|
-
if (RG.Effects && typeof RG.Effects.decorate === 'function') {
|
220
|
-
RG.Effects.decorate(this);
|
221
|
-
}
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
/**
|
227
|
-
* A generic setter
|
228
|
-
*
|
229
|
-
* @param string name The name of the property to set
|
230
|
-
* @param string value The value of the poperty
|
231
|
-
*/
|
232
|
-
this.set =
|
233
|
-
this.Set = function (name)
|
234
|
-
{
|
235
|
-
var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
|
236
|
-
|
237
|
-
/**
|
238
|
-
* the number of arguments is only one and it's an
|
239
|
-
* object - parse it for configuration data and return.
|
240
|
-
*/
|
241
|
-
if (arguments.length === 1 && typeof name === 'object') {
|
242
|
-
RG.parseObjectStyleConfig(this, name);
|
243
|
-
return this;
|
244
|
-
}
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
/**
|
251
|
-
* This should be done first - prepend the propertyy name with "chart." if necessary
|
252
|
-
*/
|
253
|
-
if (name.substr(0,6) != 'chart.') {
|
254
|
-
name = 'chart.' + name;
|
255
|
-
}
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
// Convert uppercase letters to dot+lower case letter
|
261
|
-
while(name.match(/([A-Z])/)) {
|
262
|
-
name = name.replace(/([A-Z])/, '.' + RegExp.$1.toLowerCase());
|
263
|
-
}
|
264
|
-
|
265
|
-
|
266
|
-
/**
|
267
|
-
* chart.strokestyle now sets both chart.strokestyle.inner and chart.strokestyle.outer
|
268
|
-
*/
|
269
|
-
if (name == 'chart.strokestyle') {
|
270
|
-
this.Set('chart.strokestyle.inner', value);
|
271
|
-
this.Set('chart.strokestyle.outer', value);
|
272
|
-
return;
|
273
|
-
}
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
prop[name] = value;
|
281
|
-
|
282
|
-
return this;
|
283
|
-
};
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
/**
|
289
|
-
* A generic getter
|
290
|
-
*
|
291
|
-
* @param string name The name of the property to get
|
292
|
-
*/
|
293
|
-
this.get =
|
294
|
-
this.Get = function (name)
|
295
|
-
{
|
296
|
-
/**
|
297
|
-
* This should be done first - prepend the property name with "chart." if necessary
|
298
|
-
*/
|
299
|
-
if (name.substr(0,6) != 'chart.') {
|
300
|
-
name = 'chart.' + name;
|
301
|
-
}
|
302
|
-
|
303
|
-
// Convert uppercase letters to dot+lower case letter
|
304
|
-
name = name.replace(/([A-Z])/g, function (str)
|
305
|
-
{
|
306
|
-
return '.' + String(RegExp.$1).toLowerCase()
|
307
|
-
});
|
308
|
-
|
309
|
-
return prop[name.toLowerCase()];
|
310
|
-
};
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
/**
|
316
|
-
* Draws the progress bar
|
317
|
-
*/
|
318
|
-
this.draw =
|
319
|
-
this.Draw = function ()
|
320
|
-
{
|
321
|
-
/**
|
322
|
-
* Fire the onbeforedraw event
|
323
|
-
*/
|
324
|
-
RG.fireCustomEvent(this, 'onbeforedraw');
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
/**
|
329
|
-
* Parse the colors. This allows for simple gradient syntax
|
330
|
-
*/
|
331
|
-
if (!this.colorsParsed) {
|
332
|
-
|
333
|
-
this.parseColors();
|
334
|
-
|
335
|
-
|
336
|
-
// Don't want to do this again
|
337
|
-
this.colorsParsed = true;
|
338
|
-
}
|
339
|
-
|
340
|
-
|
341
|
-
/**
|
342
|
-
* Set the current value
|
343
|
-
*/
|
344
|
-
this.currentValue = this.value;
|
345
|
-
|
346
|
-
/**
|
347
|
-
* This is new in May 2011 and facilitates individual gutter settings,
|
348
|
-
* eg chart.gutter.left
|
349
|
-
*/
|
350
|
-
this.gutterLeft = prop['chart.gutter.left'];
|
351
|
-
this.gutterRight = prop['chart.gutter.right'];
|
352
|
-
this.gutterTop = prop['chart.gutter.top'];
|
353
|
-
this.gutterBottom = prop['chart.gutter.bottom'];
|
354
|
-
|
355
|
-
// Figure out the width and height
|
356
|
-
this.width = ca.width - this.gutterLeft - this.gutterRight;
|
357
|
-
this.height = ca.height - this.gutterTop - this.gutterBottom;
|
358
|
-
this.coords = [];
|
359
|
-
this.coordsText = [];
|
360
|
-
|
361
|
-
this.drawbar();
|
362
|
-
this.DrawTickMarks();
|
363
|
-
this.DrawLabels();
|
364
|
-
this.DrawTitle();
|
365
|
-
|
366
|
-
co.stroke();
|
367
|
-
co.fill();
|
368
|
-
|
369
|
-
|
370
|
-
/**
|
371
|
-
* Draw the bevel effect if requested
|
372
|
-
*/
|
373
|
-
if (prop['chart.bevel']) {
|
374
|
-
this.DrawBevel();
|
375
|
-
}
|
376
|
-
|
377
|
-
|
378
|
-
/**
|
379
|
-
* Setup the context menu if required
|
380
|
-
*/
|
381
|
-
if (prop['chart.contextmenu']) {
|
382
|
-
RG.ShowContext(this);
|
383
|
-
}
|
384
|
-
|
385
|
-
|
386
|
-
// Draw the key if necessary
|
387
|
-
if (prop['chart.key'] && prop['chart.key'].length) {
|
388
|
-
RG.DrawKey(this, prop['chart.key'], prop['chart.colors']);
|
389
|
-
}
|
390
|
-
|
391
|
-
|
392
|
-
/**
|
393
|
-
* This function enables resizing
|
394
|
-
*/
|
395
|
-
if (prop['chart.resizable']) {
|
396
|
-
RG.AllowResizing(this);
|
397
|
-
}
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
/**
|
402
|
-
* This installs the event listeners
|
403
|
-
*/
|
404
|
-
RG.InstallEventListeners(this);
|
405
|
-
|
406
|
-
/**
|
407
|
-
* Fire the onfirstdraw event
|
408
|
-
*/
|
409
|
-
if (this.firstDraw) {
|
410
|
-
RG.fireCustomEvent(this, 'onfirstdraw');
|
411
|
-
this.firstDraw = false;
|
412
|
-
this.firstDrawFunc();
|
413
|
-
}
|
414
|
-
|
415
|
-
|
416
|
-
/**
|
417
|
-
* Fire the RGraph ondraw event
|
418
|
-
*/
|
419
|
-
RG.FireCustomEvent(this, 'ondraw');
|
420
|
-
|
421
|
-
return this;
|
422
|
-
};
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
/**
|
427
|
-
* Used in chaining. Runs a function there and then - not waiting for
|
428
|
-
* the events to fire (eg the onbeforedraw event)
|
429
|
-
*
|
430
|
-
* @param function func The function to execute
|
431
|
-
*/
|
432
|
-
this.exec = function (func)
|
433
|
-
{
|
434
|
-
func(this);
|
435
|
-
|
436
|
-
return this;
|
437
|
-
};
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
/**
|
443
|
-
* Draws the bar
|
444
|
-
*/
|
445
|
-
this.drawbar =
|
446
|
-
this.Drawbar = function ()
|
447
|
-
{
|
448
|
-
/**
|
449
|
-
* First get the scale
|
450
|
-
*/
|
451
|
-
this.scale2 = RG.getScale2(this, {
|
452
|
-
'max':this.max,
|
453
|
-
'min':this.min,
|
454
|
-
'strict':true,
|
455
|
-
'scale.thousand': prop['chart.scale.thousand'],
|
456
|
-
'scale.point': prop['chart.scale.point'],
|
457
|
-
'scale.decimals': prop['chart.scale.decimals'],
|
458
|
-
'ylabels.count': prop['chart.labels.count'],
|
459
|
-
'scale.round': prop['chart.scale.round'],
|
460
|
-
'units.pre': prop['chart.units.pre'],
|
461
|
-
'units.post': prop['chart.units.post']
|
462
|
-
});
|
463
|
-
|
464
|
-
// Set a shadow if requested
|
465
|
-
if (prop['chart.shadow']) {
|
466
|
-
RG.SetShadow(this, prop['chart.shadow.color'], prop['chart.shadow.offsetx'], prop['chart.shadow.offsety'], prop['chart.shadow.blur']);
|
467
|
-
}
|
468
|
-
|
469
|
-
// Draw the outline
|
470
|
-
co.fillStyle = prop['chart.background.color'];
|
471
|
-
co.strokeStyle = prop['chart.strokestyle.outer'];
|
472
|
-
co.strokeRect(this.gutterLeft, this.gutterTop, this.width, this.height);
|
473
|
-
co.fillRect(this.gutterLeft, this.gutterTop, this.width, this.height);
|
474
|
-
|
475
|
-
// Turn off any shadow
|
476
|
-
RG.noShadow(this);
|
477
|
-
|
478
|
-
co.fillStyle = prop['chart.colors'][0];
|
479
|
-
co.strokeStyle = prop['chart.strokestyle.outer'];
|
480
|
-
|
481
|
-
var margin = prop['chart.margin'];
|
482
|
-
|
483
|
-
// Draw the actual bar itself
|
484
|
-
var barWidth = ma.min(this.width, ((RG.array_sum(this.value) - this.min) / (this.max - this.min) ) * this.width);
|
485
|
-
|
486
|
-
if (prop['chart.tickmarks.inner']) {
|
487
|
-
|
488
|
-
var spacing = (ca.width - this.gutterLeft - this.gutterRight) / prop['chart.numticks.inner'];
|
489
|
-
|
490
|
-
co.lineWidth = 1;
|
491
|
-
co.strokeStyle = prop['chart.strokestyle.outer'];
|
492
|
-
|
493
|
-
co.beginPath();
|
494
|
-
for (var x = this.gutterLeft; x<ca.width - this.gutterRight; x+=spacing) {
|
495
|
-
co.moveTo(Math.round(x), this.gutterTop);
|
496
|
-
co.lineTo(Math.round(x), this.gutterTop + 2);
|
497
|
-
|
498
|
-
co.moveTo(Math.round(x), ca.height - this.gutterBottom);
|
499
|
-
co.lineTo(Math.round(x), ca.height - this.gutterBottom - 2);
|
500
|
-
}
|
501
|
-
co.stroke();
|
502
|
-
}
|
503
|
-
|
504
|
-
/**
|
505
|
-
* This bit draws the actual progress bar
|
506
|
-
*/
|
507
|
-
if (typeof this.value === 'number') {
|
508
|
-
|
509
|
-
if (prop['chart.border.inner']) {
|
510
|
-
this.drawCurvedBar({
|
511
|
-
x: this.gutterLeft,
|
512
|
-
y: this.gutterTop + margin,
|
513
|
-
width: barWidth,
|
514
|
-
height: this.height - margin - margin,
|
515
|
-
stroke: prop['chart.strokestyle.inner']
|
516
|
-
});
|
517
|
-
}
|
518
|
-
|
519
|
-
this.drawCurvedBar({
|
520
|
-
x: this.gutterLeft,
|
521
|
-
y: this.gutterTop + margin,
|
522
|
-
width: barWidth,
|
523
|
-
height: this.height - margin - margin,
|
524
|
-
fill: prop['chart.colors'][0]
|
525
|
-
});
|
526
|
-
|
527
|
-
// Store the coords
|
528
|
-
this.coords.push([
|
529
|
-
this.gutterLeft,
|
530
|
-
this.gutterTop + margin,
|
531
|
-
barWidth,
|
532
|
-
this.height - margin - margin
|
533
|
-
]);
|
534
|
-
|
535
|
-
} else if (typeof this.value === 'object') {
|
536
|
-
|
537
|
-
co.beginPath();
|
538
|
-
|
539
|
-
var startPoint = this.gutterLeft;
|
540
|
-
|
541
|
-
for (var i=0,len=this.value.length; i<len; ++i) {
|
542
|
-
|
543
|
-
var segmentLength = (this.value[i] / RG.arraySum(this.value)) * barWidth;
|
544
|
-
|
545
|
-
if (prop['chart.border.inner']) {
|
546
|
-
this.drawCurvedBar({
|
547
|
-
x: startPoint,
|
548
|
-
y: this.gutterTop + margin,
|
549
|
-
width: segmentLength,
|
550
|
-
height: this.height - margin - margin,
|
551
|
-
fill: prop['chart.colors'][i],
|
552
|
-
stroke: prop['chart.strokestyle.inner']
|
553
|
-
});
|
554
|
-
}
|
555
|
-
|
556
|
-
this.drawCurvedBar({
|
557
|
-
x: startPoint,
|
558
|
-
y: this.gutterTop + margin,
|
559
|
-
width: segmentLength,
|
560
|
-
height: this.height - margin - margin,
|
561
|
-
fill: prop['chart.colors'][i]
|
562
|
-
});
|
563
|
-
|
564
|
-
|
565
|
-
// Store the coords
|
566
|
-
this.coords.push([
|
567
|
-
startPoint,
|
568
|
-
this.gutterTop + margin,
|
569
|
-
segmentLength,
|
570
|
-
this.height - margin - margin
|
571
|
-
]);
|
572
|
-
|
573
|
-
startPoint += segmentLength;
|
574
|
-
}
|
575
|
-
}
|
576
|
-
|
577
|
-
/**
|
578
|
-
* Draw the arrows indicating the level if requested
|
579
|
-
*/
|
580
|
-
if (prop['chart.arrows']) {
|
581
|
-
var x = this.gutterLeft + barWidth;
|
582
|
-
var y = this.gutterTop;
|
583
|
-
|
584
|
-
co.lineWidth = 1;
|
585
|
-
co.fillStyle = 'black';
|
586
|
-
co.strokeStyle = 'black';
|
587
|
-
|
588
|
-
co.beginPath();
|
589
|
-
co.moveTo(x, y - 3);
|
590
|
-
co.lineTo(x + 2, y - 7);
|
591
|
-
co.lineTo(x - 2, y - 7);
|
592
|
-
co.closePath();
|
593
|
-
|
594
|
-
co.stroke();
|
595
|
-
co.fill();
|
596
|
-
|
597
|
-
co.beginPath();
|
598
|
-
co.moveTo(x, y + this.height + 4);
|
599
|
-
co.lineTo(x + 2, y + this.height + 9);
|
600
|
-
co.lineTo(x - 2, y + this.height + 9);
|
601
|
-
co.closePath();
|
602
|
-
|
603
|
-
co.stroke();
|
604
|
-
co.fill()
|
605
|
-
}
|
606
|
-
|
607
|
-
|
608
|
-
/**
|
609
|
-
* Draw the "in-bar" label
|
610
|
-
*/
|
611
|
-
if (prop['chart.label.inner']) {
|
612
|
-
co.fillStyle = 'black';
|
613
|
-
RG.Text2(this, {
|
614
|
-
'font':prop['chart.text.font'],
|
615
|
-
'size':prop['chart.text.size'] + 2,
|
616
|
-
'x':this.gutterLeft + barWidth + 5,
|
617
|
-
'y':this.gutterTop + (this.height / 2),
|
618
|
-
'text': String(prop['chart.units.pre'] + this.value + prop['chart.units.post']),
|
619
|
-
'valign':'bottom',
|
620
|
-
'halign':'left',
|
621
|
-
'bounding':true,
|
622
|
-
'boundingFill':'white',
|
623
|
-
'tag': 'label.inner'
|
624
|
-
});
|
625
|
-
}
|
626
|
-
};
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
/**
|
632
|
-
* The function that draws the tick marks. Apt name...
|
633
|
-
*/
|
634
|
-
this.drawTickMarks =
|
635
|
-
this.DrawTickMarks = function ()
|
636
|
-
{
|
637
|
-
co.strokeStyle = prop['chart.tickmarks.color'];
|
638
|
-
|
639
|
-
if (prop['chart.tickmarks']) {
|
640
|
-
|
641
|
-
co.beginPath();
|
642
|
-
|
643
|
-
// This is used by the label function below
|
644
|
-
this.tickInterval = this.width / prop['chart.numticks'];
|
645
|
-
|
646
|
-
var start = prop['chart.tickmarks.zerostart'] ? 0 : this.tickInterval;
|
647
|
-
|
648
|
-
if (prop['chart.labels.position'] == 'top') {
|
649
|
-
for (var i=this.gutterLeft + start; i<=(this.width + this.gutterLeft + 0.1); i+=this.tickInterval) {
|
650
|
-
co.moveTo(Math.round(i), this.gutterTop);
|
651
|
-
co.lineTo(Math.round(i), this.gutterTop - 4);
|
652
|
-
}
|
653
|
-
|
654
|
-
} else {
|
655
|
-
|
656
|
-
for (var i=this.gutterLeft + start; i<=(this.width + this.gutterLeft + 0.1); i+=this.tickInterval) {
|
657
|
-
co.moveTo(Math.round(i), this.gutterTop + this.height);
|
658
|
-
co.lineTo(Math.round(i), this.gutterTop + this.height + 4);
|
659
|
-
}
|
660
|
-
}
|
661
|
-
|
662
|
-
co.stroke();
|
663
|
-
}
|
664
|
-
};
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
/**
|
670
|
-
* The function that draws the labels
|
671
|
-
*/
|
672
|
-
this.drawLabels =
|
673
|
-
this.DrawLabels = function ()
|
674
|
-
{
|
675
|
-
if (!RG.is_null(prop['chart.labels.specific'])) {
|
676
|
-
return this.DrawSpecificLabels();
|
677
|
-
}
|
678
|
-
|
679
|
-
co.fillStyle = prop['chart.text.color'];
|
680
|
-
|
681
|
-
var xPoints = [],
|
682
|
-
yPoints = [],
|
683
|
-
font = prop['chart.text.font'],
|
684
|
-
size = prop['chart.text.size'],
|
685
|
-
offsetx = prop['chart.labels.offsetx'],
|
686
|
-
offsety = prop['chart.labels.offsety'];
|
687
|
-
|
688
|
-
for (i=0,len=this.scale2.labels.length; i<len; i++) {
|
689
|
-
|
690
|
-
|
691
|
-
if (prop['chart.labels.position'] == 'top') {
|
692
|
-
var x = this.width * (i/this.scale2.labels.length) + this.gutterLeft + (this.width / this.scale2.labels.length);
|
693
|
-
var y = this.gutterTop - 6;
|
694
|
-
var valign = 'bottom';
|
695
|
-
} else {
|
696
|
-
var x = this.width * (i/this.scale2.labels.length) + this.gutterLeft + (this.width / this.scale2.labels.length);
|
697
|
-
var y = this.height + this.gutterTop + 4;
|
698
|
-
var valign = 'top';
|
699
|
-
}
|
700
|
-
|
701
|
-
RG.text2(this, {
|
702
|
-
'font':font,
|
703
|
-
'size':size,
|
704
|
-
'x':x + offsetx,
|
705
|
-
'y':y + offsety,
|
706
|
-
'text': this.scale2.labels[i],
|
707
|
-
'valign':valign,
|
708
|
-
'halign':'center',
|
709
|
-
'tag': 'scale'
|
710
|
-
});
|
711
|
-
}
|
712
|
-
|
713
|
-
if (prop['chart.tickmarks.zerostart']) {
|
714
|
-
if (prop['chart.labels.position'] == 'top') {
|
715
|
-
RG.text2(this, {
|
716
|
-
'font':font,
|
717
|
-
'size':size,
|
718
|
-
'x':this.gutterLeft + offsetx,
|
719
|
-
'y':this.gutterTop - 6 + offsety,
|
720
|
-
'text': prop['chart.units.pre'] + Number(this.min).toFixed(prop['chart.scale.decimals']) + prop['chart.units.post'],
|
721
|
-
'valign':'bottom',
|
722
|
-
'halign':'center',
|
723
|
-
'tag': 'scale'
|
724
|
-
});
|
725
|
-
} else {
|
726
|
-
RG.text2(this, {
|
727
|
-
'font':font,
|
728
|
-
'size':size,
|
729
|
-
'x':this.gutterLeft + offsetx,
|
730
|
-
'y':ca.height - this.gutterBottom + 5 + offsety,
|
731
|
-
'text': prop['chart.units.pre'] + Number(this.min).toFixed(prop['chart.scale.decimals']) + prop['chart.units.post'],
|
732
|
-
'valign':'top',
|
733
|
-
'halign':'center',
|
734
|
-
'tag': 'scale'
|
735
|
-
});
|
736
|
-
}
|
737
|
-
}
|
738
|
-
};
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
/**
|
744
|
-
* Returns the focused bar
|
745
|
-
*
|
746
|
-
* @param event e The event object
|
747
|
-
*/
|
748
|
-
this.getShape =
|
749
|
-
this.getBar = function (e)
|
750
|
-
{
|
751
|
-
var mouseXY = RG.getMouseXY(e),
|
752
|
-
mouseX = mouseXY[0],
|
753
|
-
mouseY = mouseXY[1];
|
754
|
-
|
755
|
-
for (var i=0,len=this.coords.length; i<len; i++) {
|
756
|
-
|
757
|
-
var x = this.coords[i][0],
|
758
|
-
y = this.coords[i][1],
|
759
|
-
w = this.coords[i][2],
|
760
|
-
h = this.coords[i][3],
|
761
|
-
idx = i;
|
762
|
-
|
763
|
-
co.beginPath();
|
764
|
-
this.drawCurvedBar({
|
765
|
-
x: x,
|
766
|
-
y: y,
|
767
|
-
height: h,
|
768
|
-
width: w
|
769
|
-
});
|
770
|
-
|
771
|
-
if (co.isPointInPath(mouseX, mouseY)) {
|
772
|
-
|
773
|
-
var tooltip = RG.parseTooltipText(prop['chart.tooltips'], idx);
|
774
|
-
|
775
|
-
return {
|
776
|
-
0: this, 1: x, 2: y, 3: w, 4: h, 5: idx,
|
777
|
-
'object':this, 'x':x, 'y':y, 'width': w, 'height': h, 'index': idx, 'tooltip': tooltip
|
778
|
-
}
|
779
|
-
}
|
780
|
-
}
|
781
|
-
};
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
/**
|
787
|
-
* This function returns the value that the mouse is positioned at, regardless of
|
788
|
-
* the actual indicated value.
|
789
|
-
*
|
790
|
-
* @param object e The event object
|
791
|
-
*/
|
792
|
-
this.getValue = function (e)
|
793
|
-
{
|
794
|
-
var mouseXY = RG.getMouseXY(e);
|
795
|
-
|
796
|
-
var value = (mouseXY[0] - this.gutterLeft) / this.width;
|
797
|
-
value *= this.max - this.min;
|
798
|
-
value += this.min;
|
799
|
-
|
800
|
-
if (mouseXY[0] < this.gutterLeft) {
|
801
|
-
value = this.min;
|
802
|
-
}
|
803
|
-
if (mouseXY[0] > (ca.width - this.gutterRight) ) {
|
804
|
-
value = this.max
|
805
|
-
}
|
806
|
-
|
807
|
-
return value;
|
808
|
-
};
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
/**
|
814
|
-
* Each object type has its own Highlight() function which highlights the appropriate shape
|
815
|
-
*
|
816
|
-
* @param object shape The shape to highlight
|
817
|
-
*/
|
818
|
-
this.highlight =
|
819
|
-
this.Highlight = function (shape)
|
820
|
-
{
|
821
|
-
var last = shape.index === this.coords.length - 1;
|
822
|
-
|
823
|
-
if (typeof prop['chart.highlight.style'] === 'function') {
|
824
|
-
(prop['chart.highlight.style'])(shape);
|
825
|
-
} else {
|
826
|
-
|
827
|
-
this.drawCurvedBar({
|
828
|
-
x: shape.x,
|
829
|
-
y: shape.y,
|
830
|
-
width: shape.width,
|
831
|
-
height: shape.height,
|
832
|
-
stroke: prop['chart.highlight.stroke'],
|
833
|
-
fill: prop['chart.highlight.fill']
|
834
|
-
});
|
835
|
-
}
|
836
|
-
};
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
/**
|
842
|
-
* The getObjectByXY() worker method. Don't call this call:
|
843
|
-
*
|
844
|
-
* RGraph.ObjectRegistry.getObjectByXY(e)
|
845
|
-
*
|
846
|
-
* @param object e The event object
|
847
|
-
*/
|
848
|
-
this.getObjectByXY = function (e)
|
849
|
-
{
|
850
|
-
var mouseXY = RG.getMouseXY(e);
|
851
|
-
|
852
|
-
if (
|
853
|
-
mouseXY[0] > this.gutterLeft
|
854
|
-
&& mouseXY[0] < (ca.width - this.gutterRight)
|
855
|
-
&& mouseXY[1] > this.gutterTop
|
856
|
-
&& mouseXY[1] < (ca.height - this.gutterBottom)
|
857
|
-
) {
|
858
|
-
|
859
|
-
return this;
|
860
|
-
}
|
861
|
-
};
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
/**
|
867
|
-
* This method handles the adjusting calculation for when the mouse is moved
|
868
|
-
*
|
869
|
-
* @param object e The event object
|
870
|
-
*/
|
871
|
-
this.adjusting_mousemove =
|
872
|
-
this.Adjusting_mousemove = function (e)
|
873
|
-
{
|
874
|
-
/**
|
875
|
-
* Handle adjusting for the HProgress
|
876
|
-
*/
|
877
|
-
if (prop['chart.adjustable'] && RG.Registry.Get('chart.adjusting') && RG.Registry.Get('chart.adjusting').uid == this.uid) {
|
878
|
-
|
879
|
-
var mouseXY = RG.getMouseXY(e);
|
880
|
-
var value = this.getValue(e);
|
881
|
-
|
882
|
-
if (typeof(value) == 'number') {
|
883
|
-
|
884
|
-
this.value = Number(value.toFixed(prop['chart.scale.decimals']));
|
885
|
-
RG.redrawCanvas(ca);
|
886
|
-
|
887
|
-
// Fire the onadjust event
|
888
|
-
RG.fireCustomEvent(this, 'onadjust');
|
889
|
-
}
|
890
|
-
}
|
891
|
-
};
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
/**
|
897
|
-
* Draws chart.labels.specific
|
898
|
-
*/
|
899
|
-
this.drawSpecificLabels =
|
900
|
-
this.DrawSpecificLabels = function ()
|
901
|
-
{
|
902
|
-
var labels = prop['chart.labels.specific'];
|
903
|
-
|
904
|
-
if (labels) {
|
905
|
-
|
906
|
-
var font = prop['chart.text.font'],
|
907
|
-
size = prop['chart.text.size'],
|
908
|
-
valign = (prop['chart.labels.position'] == 'top' ? 'bottom' : 'top'),
|
909
|
-
step = this.width / (labels.length - 1),
|
910
|
-
offsetx = prop['chart.labels.offsetx'],
|
911
|
-
offsety = prop['chart.labels.offsety']
|
912
|
-
|
913
|
-
co.beginPath();
|
914
|
-
co.fillStyle = prop['chart.text.color'];
|
915
|
-
for (var i=0; i<labels.length; ++i) {
|
916
|
-
RG.Text2(this, {
|
917
|
-
font:font,
|
918
|
-
size:size,
|
919
|
-
x: this.gutterLeft + (step * i) + offsetx,
|
920
|
-
y: prop['chart.labels.position'] == 'top' ? this.gutterTop - 7 + offsety: ca.height - this.gutterBottom + 7 + offsety,
|
921
|
-
text: labels[i],
|
922
|
-
valign:valign,
|
923
|
-
halign:'center',
|
924
|
-
tag: 'labels.specific'
|
925
|
-
});
|
926
|
-
}
|
927
|
-
co.fill();
|
928
|
-
}
|
929
|
-
};
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
/**
|
935
|
-
* This function positions a tooltip when it is displayed
|
936
|
-
*
|
937
|
-
* @param obj object The chart object
|
938
|
-
* @param int x The X coordinate specified for the tooltip
|
939
|
-
* @param int y The Y coordinate specified for the tooltip
|
940
|
-
* @param objec tooltip The tooltips DIV element
|
941
|
-
*/
|
942
|
-
this.positionTooltip = function (obj, x, y, tooltip, idx)
|
943
|
-
{
|
944
|
-
var coordX = obj.coords[tooltip.__index__][0];
|
945
|
-
var coordY = obj.coords[tooltip.__index__][1];
|
946
|
-
var coordW = obj.coords[tooltip.__index__][2];
|
947
|
-
var coordH = obj.coords[tooltip.__index__][3];
|
948
|
-
var canvasXY = RG.getCanvasXY(obj.canvas);
|
949
|
-
var gutterLeft = this.gutterLeft;
|
950
|
-
var gutterTop = this.gutterTop;
|
951
|
-
var width = tooltip.offsetWidth;
|
952
|
-
var height = tooltip.offsetHeight;
|
953
|
-
var mouseXY = RG.getMouseXY(window.event);
|
954
|
-
|
955
|
-
// Set the top position
|
956
|
-
tooltip.style.left = 0;
|
957
|
-
tooltip.style.top = window.event.pageY - height - 5 + 'px';
|
958
|
-
|
959
|
-
// By default any overflow is hidden
|
960
|
-
tooltip.style.overflow = '';
|
961
|
-
|
962
|
-
// Reposition the tooltip if at the edges:
|
963
|
-
|
964
|
-
// LEFT edge
|
965
|
-
if (canvasXY[0] + mouseXY[0] - (width / 2) < 0) {
|
966
|
-
tooltip.style.left = canvasXY[0] + mouseXY[0] - (width * 0.1) + 'px';
|
967
|
-
|
968
|
-
// RIGHT edge
|
969
|
-
} else if (canvasXY[0] + mouseXY[0] + (width / 2) > doc.body.offsetWidth) {
|
970
|
-
tooltip.style.left = canvasXY[0] + mouseXY[0] - (width * 0.9) + 'px';
|
971
|
-
|
972
|
-
// Default positioning - CENTERED
|
973
|
-
} else {
|
974
|
-
tooltip.style.left = canvasXY[0] + mouseXY[0] - (width / 2) + 'px';
|
975
|
-
}
|
976
|
-
};
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
/**
|
982
|
-
* This function returns the appropriate X coordinate for the given value
|
983
|
-
*
|
984
|
-
* @param int value The value you want the coordinate for
|
985
|
-
* @returm int The coordinate
|
986
|
-
*/
|
987
|
-
this.getXCoord = function (value)
|
988
|
-
{
|
989
|
-
var min = this.min;
|
990
|
-
|
991
|
-
if (value < min || value > this.max) {
|
992
|
-
return null;
|
993
|
-
}
|
994
|
-
|
995
|
-
var barWidth = ca.width - this.gutterLeft - this.gutterRight;
|
996
|
-
var coord = ((value - min) / (this.max - min)) * barWidth;
|
997
|
-
coord = this.gutterLeft + coord;
|
998
|
-
|
999
|
-
return coord;
|
1000
|
-
};
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
/**
|
1006
|
-
* This returns true/false as to whether the cursor is over the chart area.
|
1007
|
-
* The cursor does not necessarily have to be over the bar itself.
|
1008
|
-
*/
|
1009
|
-
this.overChartArea = function (e)
|
1010
|
-
{
|
1011
|
-
var mouseXY = RGraph.getMouseXY(e);
|
1012
|
-
var mouseX = mouseXY[0];
|
1013
|
-
var mouseY = mouseXY[1];
|
1014
|
-
|
1015
|
-
if ( mouseX >= this.gutterLeft
|
1016
|
-
&& mouseX <= (ca.width - this.gutterRight)
|
1017
|
-
&& mouseY >= this.gutterTop
|
1018
|
-
&& mouseY <= (ca.height - this.gutterBottom)
|
1019
|
-
) {
|
1020
|
-
|
1021
|
-
return true;
|
1022
|
-
}
|
1023
|
-
|
1024
|
-
return false;
|
1025
|
-
};
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
/**
|
1031
|
-
*
|
1032
|
-
*/
|
1033
|
-
this.parseColors = function ()
|
1034
|
-
{
|
1035
|
-
|
1036
|
-
// Save the original colors so that they can be restored when the canvas is reset
|
1037
|
-
if (this.original_colors.length === 0) {
|
1038
|
-
this.original_colors['chart.colors'] = RG.array_clone(prop['chart.colors']);
|
1039
|
-
this.original_colors['chart.tickmarks.color'] = RG.array_clone(prop['chart.tickmarks.color']);
|
1040
|
-
this.original_colors['chart.strokestyle.inner'] = RG.array_clone(prop['chart.strokestyle.inner']);
|
1041
|
-
this.original_colors['chart.strokestyle.outer'] = RG.array_clone(prop['chart.strokestyle.outer']);
|
1042
|
-
this.original_colors['chart.highlight.fill'] = RG.array_clone(prop['chart.highlight.fill']);
|
1043
|
-
this.original_colors['chart.highlight.stroke'] = RG.array_clone(prop['chart.highlight.stroke']);
|
1044
|
-
this.original_colors['chart.highlight.color'] = RG.array_clone(prop['chart.highlight.color']);
|
1045
|
-
}
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
var colors = prop['chart.colors'];
|
1051
|
-
|
1052
|
-
for (var i=0; i<colors.length; ++i) {
|
1053
|
-
colors[i] = this.parseSingleColorForGradient(colors[i]);
|
1054
|
-
}
|
1055
|
-
|
1056
|
-
prop['chart.tickmarks.color'] = this.parseSingleColorForGradient(prop['chart.tickmarks.color']);
|
1057
|
-
prop['chart.strokestyle.inner'] = this.parseSingleColorForGradient(prop['chart.strokestyle.inner']);
|
1058
|
-
prop['chart.strokestyle.outer'] = this.parseSingleColorForGradient(prop['chart.strokestyle.outer']);
|
1059
|
-
prop['chart.highlight.fill'] = this.parseSingleColorForGradient(prop['chart.highlight.fill']);
|
1060
|
-
prop['chart.highlight.stroke'] = this.parseSingleColorForGradient(prop['chart.highlight.stroke']);
|
1061
|
-
prop['chart.background.color'] = this.parseSingleColorForGradient(prop['chart.background.color']);
|
1062
|
-
};
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
/**
|
1068
|
-
* Use this function to reset the object to the post-constructor state. Eg reset colors if
|
1069
|
-
* need be etc
|
1070
|
-
*/
|
1071
|
-
this.reset = function ()
|
1072
|
-
{
|
1073
|
-
};
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
/**
|
1079
|
-
* This parses a single color value
|
1080
|
-
*/
|
1081
|
-
this.parseSingleColorForGradient = function (color)
|
1082
|
-
{
|
1083
|
-
if (!color || typeof(color) != 'string') {
|
1084
|
-
return color;
|
1085
|
-
}
|
1086
|
-
|
1087
|
-
if (color.match(/^gradient\((.*)\)$/i)) {
|
1088
|
-
|
1089
|
-
var parts = RegExp.$1.split(':');
|
1090
|
-
|
1091
|
-
// Create the gradient
|
1092
|
-
var grad = co.createLinearGradient(prop['chart.gutter.left'],0,ca.width - prop['chart.gutter.right'],0);
|
1093
|
-
|
1094
|
-
var diff = 1 / (parts.length - 1);
|
1095
|
-
|
1096
|
-
grad.addColorStop(0, RG.trim(parts[0]));
|
1097
|
-
|
1098
|
-
for (var j=1; j<parts.length; ++j) {
|
1099
|
-
grad.addColorStop(j * diff, RG.trim(parts[j]));
|
1100
|
-
}
|
1101
|
-
}
|
1102
|
-
|
1103
|
-
return grad ? grad : color;
|
1104
|
-
};
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
/**
|
1110
|
-
* Draws the bevel effect
|
1111
|
-
*/
|
1112
|
-
this.drawBevel =
|
1113
|
-
this.DrawBevel = function ()
|
1114
|
-
{
|
1115
|
-
// In case of multiple segments - this adds up all the lengths
|
1116
|
-
for (var i=0,len=0; i<this.coords.length; ++i) len += this.coords[i][2];
|
1117
|
-
|
1118
|
-
co.save();
|
1119
|
-
// Draw a path to clip to
|
1120
|
-
co.beginPath();
|
1121
|
-
co.rect(
|
1122
|
-
this.coords[0][0],
|
1123
|
-
this.coords[0][1],
|
1124
|
-
len,
|
1125
|
-
this.coords[0][3]
|
1126
|
-
);
|
1127
|
-
co.clip();
|
1128
|
-
|
1129
|
-
co.save();
|
1130
|
-
// Draw a path to clip to
|
1131
|
-
co.beginPath();
|
1132
|
-
this.drawCurvedBar({
|
1133
|
-
x: this.coords[0][0],
|
1134
|
-
y: this.coords[0][1],
|
1135
|
-
width: len,
|
1136
|
-
height: this.coords[0][3]
|
1137
|
-
});
|
1138
|
-
co.clip();
|
1139
|
-
|
1140
|
-
// Now draw the rect with a shadow
|
1141
|
-
co.beginPath();
|
1142
|
-
|
1143
|
-
co.shadowColor = 'black';
|
1144
|
-
co.shadowOffsetX = 0;
|
1145
|
-
co.shadowOffsetY = 0;
|
1146
|
-
co.shadowBlur = 15;
|
1147
|
-
|
1148
|
-
co.lineWidth = 2;
|
1149
|
-
|
1150
|
-
this.drawCurvedBar({
|
1151
|
-
x: this.coords[0][0] - 51,
|
1152
|
-
y: this.coords[0][1] - 1,
|
1153
|
-
width: len + 52,
|
1154
|
-
height: this.coords[0][3] + 2
|
1155
|
-
});
|
1156
|
-
|
1157
|
-
co.stroke();
|
1158
|
-
|
1159
|
-
co.restore();
|
1160
|
-
co.restore();
|
1161
|
-
};
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
/**
|
1167
|
-
* Draw the titles
|
1168
|
-
*/
|
1169
|
-
this.drawTitle =
|
1170
|
-
this.DrawTitle = function ()
|
1171
|
-
{
|
1172
|
-
// Draw the title text
|
1173
|
-
if (prop['chart.title'].length) {
|
1174
|
-
|
1175
|
-
var x = ((ca.width - this.gutterLeft - this.gutterRight) / 2) + this.gutterLeft;
|
1176
|
-
var text = prop['chart.title'];
|
1177
|
-
var size = prop['chart.title.size'] ? prop['chart.title.size'] : prop['chart.text.size'] + 2;
|
1178
|
-
var font = prop['chart.title.font'] ? prop['chart.title.font'] : prop['chart.text.font'];
|
1179
|
-
|
1180
|
-
if (prop['chart.labels.position'] == 'top') {
|
1181
|
-
y = ca.height - this.gutterBottom +5;
|
1182
|
-
x = ((ca.width - this.gutterLeft - this.gutterRight) / 2) + this.gutterLeft;
|
1183
|
-
valign = 'top';
|
1184
|
-
} else {
|
1185
|
-
x = ((ca.width - this.gutterLeft - this.gutterRight) / 2) + this.gutterLeft;
|
1186
|
-
y = this.gutterTop - 5;
|
1187
|
-
valign = 'bottom';
|
1188
|
-
}
|
1189
|
-
|
1190
|
-
|
1191
|
-
RG.Text2(this, {
|
1192
|
-
'font':font,
|
1193
|
-
'size':size,
|
1194
|
-
'x': typeof(prop['chart.title.x']) == 'number' ? prop['chart.title.x'] : x,
|
1195
|
-
'y': typeof(prop['chart.title.y']) == 'number' ? prop['chart.title.y'] : y,
|
1196
|
-
'text': text,
|
1197
|
-
'valign': prop['chart.title.valign'] ? prop['chart.title.valign'] : valign,
|
1198
|
-
'halign': prop['chart.title.halign'] ? prop['chart.title.halign'] : 'center',
|
1199
|
-
'bold':prop['chart.title.bold'],
|
1200
|
-
'bounding': prop['chart.title.background'] ? true : false,
|
1201
|
-
'boundingFill': prop['chart.title.background'],
|
1202
|
-
'tag': 'title'
|
1203
|
-
});
|
1204
|
-
}
|
1205
|
-
};
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
/**
|
1211
|
-
* This function handles highlighting an entire data-series for the interactive
|
1212
|
-
* key
|
1213
|
-
*
|
1214
|
-
* @param int index The index of the data series to be highlighted
|
1215
|
-
*/
|
1216
|
-
this.interactiveKeyHighlight = function (index)
|
1217
|
-
{
|
1218
|
-
var coords = this.coords[index];
|
1219
|
-
|
1220
|
-
co.beginPath();
|
1221
|
-
|
1222
|
-
co.strokeStyle = prop['chart.key.interactive.highlight.chart.stroke'];
|
1223
|
-
co.lineWidth = 2;
|
1224
|
-
co.fillStyle = prop['chart.key.interactive.highlight.chart.fill'];
|
1225
|
-
|
1226
|
-
co.rect(coords[0], coords[1], coords[2], coords[3]);
|
1227
|
-
co.fill();
|
1228
|
-
co.stroke();
|
1229
|
-
|
1230
|
-
// Reset the linewidth
|
1231
|
-
co.lineWidth = 1;
|
1232
|
-
};
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
/**
|
1238
|
-
* Using a function to add events makes it easier to facilitate method chaining
|
1239
|
-
*
|
1240
|
-
* @param string type The type of even to add
|
1241
|
-
* @param function func
|
1242
|
-
*/
|
1243
|
-
this.on = function (type, func)
|
1244
|
-
{
|
1245
|
-
if (type.substr(0,2) !== 'on') {
|
1246
|
-
type = 'on' + type;
|
1247
|
-
}
|
1248
|
-
|
1249
|
-
this[type] = func;
|
1250
|
-
|
1251
|
-
return this;
|
1252
|
-
};
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
/**
|
1258
|
-
* Draws a bar with a curved end.
|
1259
|
-
*
|
1260
|
-
* DOESN'T DRAW A CURVED BAR ANY MORE - JUST A REGULAR SQUARE ENDED BAR
|
1261
|
-
*
|
1262
|
-
* @param object opt The coords and colours
|
1263
|
-
*/
|
1264
|
-
this.drawCurvedBar = function (opt)
|
1265
|
-
{
|
1266
|
-
pa2(co, 'b r % % % %',
|
1267
|
-
opt.x, opt.y,
|
1268
|
-
opt.width, opt.height
|
1269
|
-
);
|
1270
|
-
|
1271
|
-
if (opt.stroke) {
|
1272
|
-
co.strokeStyle = opt.stroke;
|
1273
|
-
co.stroke();
|
1274
|
-
}
|
1275
|
-
|
1276
|
-
if (opt.fill) {
|
1277
|
-
co.fillStyle = opt.fill;
|
1278
|
-
co.fill();
|
1279
|
-
}
|
1280
|
-
}
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
/**
|
1286
|
-
* This function runs once only
|
1287
|
-
* (put at the end of the file (before any effects))
|
1288
|
-
*/
|
1289
|
-
this.firstDrawFunc = function ()
|
1290
|
-
{
|
1291
|
-
};
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
/**
|
1297
|
-
* HProgress Grow effect (which is also the VPogress Grow effect)
|
1298
|
-
*
|
1299
|
-
* @param object obj The chart object
|
1300
|
-
*/
|
1301
|
-
this.grow = function ()
|
1302
|
-
{
|
1303
|
-
var obj = this;
|
1304
|
-
var canvas = obj.canvas;
|
1305
|
-
var context = obj.context;
|
1306
|
-
var initial_value = obj.currentValue;
|
1307
|
-
var opt = arguments[0] || {};
|
1308
|
-
var numFrames = opt.frames || 30;
|
1309
|
-
var frame = 0
|
1310
|
-
var callback = arguments[1] || function () {};
|
1311
|
-
|
1312
|
-
if (typeof obj.value === 'object') {
|
1313
|
-
|
1314
|
-
if (RG.is_null(obj.currentValue)) {
|
1315
|
-
obj.currentValue = [];
|
1316
|
-
for (var i=0,len=obj.value.length; i<len; ++i) {
|
1317
|
-
obj.currentValue[i] = 0;
|
1318
|
-
}
|
1319
|
-
}
|
1320
|
-
|
1321
|
-
var diff = [];
|
1322
|
-
var increment = [];
|
1323
|
-
|
1324
|
-
for (var i=0,len=obj.value.length; i<len; ++i) {
|
1325
|
-
diff[i] = obj.value[i] - Number(obj.currentValue[i]);
|
1326
|
-
increment[i] = diff[i] / numFrames;
|
1327
|
-
}
|
1328
|
-
|
1329
|
-
if (initial_value == null) {
|
1330
|
-
initial_value = [];
|
1331
|
-
for (var i=0,len=obj.value.length; i<len; ++i) {
|
1332
|
-
initial_value[i] = 0;
|
1333
|
-
}
|
1334
|
-
}
|
1335
|
-
|
1336
|
-
} else {
|
1337
|
-
|
1338
|
-
var diff = obj.value - Number(obj.currentValue);
|
1339
|
-
var increment = diff / numFrames;
|
1340
|
-
}
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
function iterator ()
|
1348
|
-
{
|
1349
|
-
frame++;
|
1350
|
-
|
1351
|
-
if (frame <= numFrames) {
|
1352
|
-
|
1353
|
-
if (typeof obj.value == 'object') {
|
1354
|
-
obj.value = [];
|
1355
|
-
for (var i=0,len=initial_value.length; i<len; ++i) {
|
1356
|
-
obj.value[i] = initial_value[i] + (increment[i] * frame);
|
1357
|
-
}
|
1358
|
-
} else {
|
1359
|
-
obj.value = initial_value + (increment * frame);
|
1360
|
-
}
|
1361
|
-
|
1362
|
-
RGraph.clear(obj.canvas);
|
1363
|
-
RGraph.redrawCanvas(obj.canvas);
|
1364
|
-
|
1365
|
-
RGraph.Effects.updateCanvas(iterator);
|
1366
|
-
} else {
|
1367
|
-
callback();
|
1368
|
-
}
|
1369
|
-
}
|
1370
|
-
|
1371
|
-
iterator();
|
1372
|
-
|
1373
|
-
return this;
|
1374
|
-
};
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
RG.att(ca);
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
/**
|
1384
|
-
* Register the object for redrawing
|
1385
|
-
*/
|
1386
|
-
RG.Register(this);
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
/**
|
1392
|
-
* This is the 'end' of the constructor so if the first argument
|
1393
|
-
* contains configuration data - handle that.
|
1394
|
-
*/
|
1395
|
-
if (parseConfObjectForOptions) {
|
1396
|
-
RG.parseObjectStyleConfig(this, conf.options);
|
1397
|
-
}
|
1398
|
-
};
|
2
|
+
RGraph=window.RGraph||{isRGraph:true};RGraph.HProgress=function(conf)
|
3
|
+
{if(typeof conf==='object'&&typeof conf.value!=='undefined'&&typeof conf.id==='string'){var id=conf.id,canvas=document.getElementById(id),min=conf.min,max=conf.max,value=conf.value,parseConfObjectForOptions=true;}else{var id=conf,canvas=document.getElementById(id),min=arguments[1],max=arguments[2],value=arguments[3];}
|
4
|
+
this.id=id;this.canvas=canvas;this.context=this.canvas.getContext('2d');this.canvas.__object__=this;this.min=RGraph.stringsToNumbers(min);this.max=RGraph.stringsToNumbers(max);this.value=RGraph.stringsToNumbers(value);this.type='hprogress';this.coords=[];this.isRGraph=true;this.currentValue=null;this.uid=RGraph.CreateUID();this.canvas.uid=this.canvas.uid?this.canvas.uid:RGraph.CreateUID();this.colorsParsed=false;this.coordsText=[];this.original_colors=[];this.firstDraw=true;this.properties={'chart.colors':['Gradient(white:#0c0)','Gradient(white:red)','Gradient(white:green)','yellow','pink','cyan','black','white','gray'],'chart.strokestyle.inner':'#999','chart.strokestyle.outer':'#999','chart.tickmarks':true,'chart.tickmarks.color':'#999','chart.tickmarks.inner':false,'chart.tickmarks.zerostart':true,'chart.gutter.left':25,'chart.gutter.right':25,'chart.gutter.top':25,'chart.gutter.bottom':25,'chart.numticks':10,'chart.numticks.inner':50,'chart.background.color':'Gradient(#ccc:#eee:#efefef)','chart.shadow':false,'chart.shadow.color':'rgba(0,0,0,0.5)','chart.shadow.blur':3,'chart.shadow.offsetx':3,'chart.shadow.offsety':3,'chart.title':'','chart.title.background':null,'chart.title.bold':true,'chart.title.font':null,'chart.title.x':null,'chart.title.y':null,'chart.title.halign':null,'chart.title.valign':null,'chart.text.size':12,'chart.text.color':'black','chart.text.font':'Segoe UI, Arial, Verdana, sans-serif','chart.text.accessible':true,'chart.text.accessible.overflow':'visible','chart.text.accessible.pointerevents':true,'chart.contextmenu':null,'chart.units.pre':'','chart.units.post':'','chart.tooltips':null,'chart.tooltips.effect':'fade','chart.tooltips.css.class':'RGraph_tooltip','chart.tooltips.highlight':true,'chart.tooltips.event':'onclick','chart.highlight.stroke':'rgba(0,0,0,0)','chart.highlight.fill':'rgba(255,255,255,0.7)','chart.annotatable':false,'chart.annotate.color':'black','chart.zoom.factor':1.5,'chart.zoom.fade.in':true,'chart.zoom.fade.out':true,'chart.zoom.hdir':'right','chart.zoom.vdir':'down','chart.zoom.frames':25,'chart.zoom.delay':16.666,'chart.zoom.shadow':true,'chart.zoom.background':true,'chart.arrows':false,'chart.margin':0,'chart.resizable':false,'chart.resize.handle.adjust':[0,0],'chart.resize.handle.background':null,'chart.labels.specific':null,'chart.labels.count':10,'chart.labels.offsetx':0,'chart.labels.offsety':0,'chart.adjustable':false,'chart.scale.decimals':0,'chart.scale.point':'.','chart.scale.thousand':',','chart.key':null,'chart.key.background':'white','chart.key.position':'gutter','chart.key.halign':'right','chart.key.shadow':false,'chart.key.shadow.color':'#666','chart.key.shadow.blur':3,'chart.key.shadow.offsetx':2,'chart.key.shadow.offsety':2,'chart.key.position.gutter.boxed':false,'chart.key.position.x':null,'chart.key.position.y':null,'chart.key.color.shape':'square','chart.key.rounded':true,'chart.key.linewidth':1,'chart.key.colors':null,'chart.key.color.shape':'square','chart.key.interactive':false,'chart.key.interactive.highlight.chart.stroke':'black','chart.key.interactive.highlight.chart.fill':'rgba(255,255,255,0.7)','chart.key.interactive.highlight.label':'rgba(255,0,0,0.2)','chart.key.text.color':'black','chart.labels.position':'bottom','chart.events.mousemove':null,'chart.events.click':null,'chart.border.inner':true,'chart.clearto':'rgba(0,0,0,0)'}
|
5
|
+
if(!this.canvas){alert('[HPROGRESS] No canvas support');return;}
|
6
|
+
var linear_data=RGraph.array_linearize(value);for(var i=0;i<linear_data.length;++i){this['$'+i]={};}
|
7
|
+
if(!this.canvas.__rgraph_aa_translated__){this.context.translate(0.5,0.5);this.canvas.__rgraph_aa_translated__=true;}
|
8
|
+
var RG=RGraph,ca=this.canvas,co=ca.getContext('2d'),prop=this.properties,pa2=RG.path2,win=window,doc=document,ma=Math
|
9
|
+
if(RG.Effects&&typeof RG.Effects.decorate==='function'){RG.Effects.decorate(this);}
|
10
|
+
this.set=this.Set=function(name)
|
11
|
+
{var value=typeof arguments[1]==='undefined'?null:arguments[1];if(arguments.length===1&&typeof name==='object'){RG.parseObjectStyleConfig(this,name);return this;}
|
12
|
+
if(name.substr(0,6)!='chart.'){name='chart.'+name;}
|
13
|
+
while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
|
14
|
+
if(name=='chart.strokestyle'){this.Set('chart.strokestyle.inner',value);this.Set('chart.strokestyle.outer',value);return;}
|
15
|
+
prop[name]=value;return this;};this.get=this.Get=function(name)
|
16
|
+
{if(name.substr(0,6)!='chart.'){name='chart.'+name;}
|
17
|
+
while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
|
18
|
+
return prop[name.toLowerCase()];};this.draw=this.Draw=function()
|
19
|
+
{RG.fireCustomEvent(this,'onbeforedraw');if(!this.colorsParsed){this.parseColors();this.colorsParsed=true;}
|
20
|
+
this.currentValue=this.value;this.gutterLeft=prop['chart.gutter.left'];this.gutterRight=prop['chart.gutter.right'];this.gutterTop=prop['chart.gutter.top'];this.gutterBottom=prop['chart.gutter.bottom'];this.width=ca.width-this.gutterLeft-this.gutterRight;this.height=ca.height-this.gutterTop-this.gutterBottom;this.coords=[];this.coordsText=[];this.drawbar();this.DrawTickMarks();this.DrawLabels();this.DrawTitle();if(prop['chart.bevel']){this.DrawBevel();}
|
21
|
+
if(prop['chart.contextmenu']){RG.ShowContext(this);}
|
22
|
+
if(prop['chart.key']&&prop['chart.key'].length){RG.DrawKey(this,prop['chart.key'],prop['chart.colors']);}
|
23
|
+
if(prop['chart.resizable']){RG.AllowResizing(this);}
|
24
|
+
RG.InstallEventListeners(this);if(this.firstDraw){RG.fireCustomEvent(this,'onfirstdraw');this.firstDraw=false;this.firstDrawFunc();}
|
25
|
+
RG.FireCustomEvent(this,'ondraw');return this;};this.exec=function(func)
|
26
|
+
{func(this);return this;};this.drawbar=this.Drawbar=function()
|
27
|
+
{this.scale2=RG.getScale2(this,{'max':this.max,'min':this.min,'strict':true,'scale.thousand':prop['chart.scale.thousand'],'scale.point':prop['chart.scale.point'],'scale.decimals':prop['chart.scale.decimals'],'ylabels.count':prop['chart.labels.count'],'scale.round':prop['chart.scale.round'],'units.pre':prop['chart.units.pre'],'units.post':prop['chart.units.post']});if(prop['chart.shadow']){RG.SetShadow(this,prop['chart.shadow.color'],prop['chart.shadow.offsetx'],prop['chart.shadow.offsety'],prop['chart.shadow.blur']);}
|
28
|
+
co.fillStyle=prop['chart.background.color'];co.strokeStyle=prop['chart.strokestyle.outer'];co.strokeRect(this.gutterLeft,this.gutterTop,this.width,this.height);co.fillRect(this.gutterLeft,this.gutterTop,this.width,this.height);RG.noShadow(this);co.fillStyle=prop['chart.colors'][0];co.strokeStyle=prop['chart.strokestyle.outer'];var margin=prop['chart.margin'];var barWidth=ma.min(this.width,((RG.array_sum(this.value)-this.min)/(this.max-this.min))*this.width);if(prop['chart.tickmarks.inner']){var spacing=(ca.width-this.gutterLeft-this.gutterRight)/prop['chart.numticks.inner'];co.lineWidth=1;co.strokeStyle=prop['chart.strokestyle.outer'];co.beginPath();for(var x=this.gutterLeft;x<ca.width-this.gutterRight;x+=spacing){co.moveTo(Math.round(x),this.gutterTop);co.lineTo(Math.round(x),this.gutterTop+2);co.moveTo(Math.round(x),ca.height-this.gutterBottom);co.lineTo(Math.round(x),ca.height-this.gutterBottom-2);}
|
29
|
+
co.stroke();}
|
30
|
+
if(typeof this.value==='number'){if(prop['chart.border.inner']){this.drawCurvedBar({x:this.gutterLeft,y:this.gutterTop+margin,width:barWidth,height:this.height-margin-margin,stroke:prop['chart.strokestyle.inner']});}
|
31
|
+
this.drawCurvedBar({x:this.gutterLeft,y:this.gutterTop+margin,width:barWidth,height:this.height-margin-margin,fill:prop['chart.colors'][0]});this.coords.push([this.gutterLeft,this.gutterTop+margin,barWidth,this.height-margin-margin]);}else if(typeof this.value==='object'){co.beginPath();var startPoint=this.gutterLeft;for(var i=0,len=this.value.length;i<len;++i){var segmentLength=(this.value[i]/RG.arraySum(this.value))*barWidth;if(prop['chart.border.inner']){this.drawCurvedBar({x:startPoint,y:this.gutterTop+margin,width:segmentLength,height:this.height-margin-margin,fill:prop['chart.colors'][i],stroke:prop['chart.strokestyle.inner']});}
|
32
|
+
this.drawCurvedBar({x:startPoint,y:this.gutterTop+margin,width:segmentLength,height:this.height-margin-margin,fill:prop['chart.colors'][i]});this.coords.push([startPoint,this.gutterTop+margin,segmentLength,this.height-margin-margin]);startPoint+=segmentLength;}}
|
33
|
+
if(prop['chart.arrows']){var x=this.gutterLeft+barWidth;var y=this.gutterTop;co.lineWidth=1;co.fillStyle='black';co.strokeStyle='black';co.beginPath();co.moveTo(x,y-3);co.lineTo(x+2,y-7);co.lineTo(x-2,y-7);co.closePath();co.stroke();co.fill();co.beginPath();co.moveTo(x,y+this.height+4);co.lineTo(x+2,y+this.height+9);co.lineTo(x-2,y+this.height+9);co.closePath();co.stroke();co.fill()}
|
34
|
+
if(prop['chart.label.inner']){co.fillStyle='black';RG.Text2(this,{'font':prop['chart.text.font'],'size':prop['chart.text.size']+2,'x':this.gutterLeft+barWidth+5,'y':this.gutterTop+(this.height/2),'text':String(prop['chart.units.pre']+this.value+prop['chart.units.post']),'valign':'bottom','halign':'left','bounding':true,'boundingFill':'white','tag':'label.inner'});}
|
35
|
+
pa2(co,'b');};this.drawTickMarks=this.DrawTickMarks=function()
|
36
|
+
{co.strokeStyle=prop['chart.tickmarks.color'];if(prop['chart.tickmarks']){co.beginPath();this.tickInterval=this.width/prop['chart.numticks'];var start=prop['chart.tickmarks.zerostart']?0:this.tickInterval;if(prop['chart.labels.position']=='top'){for(var i=this.gutterLeft+start;i<=(this.width+this.gutterLeft+0.1);i+=this.tickInterval){co.moveTo(Math.round(i),this.gutterTop);co.lineTo(Math.round(i),this.gutterTop-4);}}else{for(var i=this.gutterLeft+start;i<=(this.width+this.gutterLeft+0.1);i+=this.tickInterval){co.moveTo(Math.round(i),this.gutterTop+this.height);co.lineTo(Math.round(i),this.gutterTop+this.height+4);}}
|
37
|
+
co.stroke();}};this.drawLabels=this.DrawLabels=function()
|
38
|
+
{if(!RG.is_null(prop['chart.labels.specific'])){return this.DrawSpecificLabels();}
|
39
|
+
co.fillStyle=prop['chart.text.color'];var xPoints=[],yPoints=[],font=prop['chart.text.font'],size=prop['chart.text.size'],offsetx=prop['chart.labels.offsetx'],offsety=prop['chart.labels.offsety'];for(i=0,len=this.scale2.labels.length;i<len;i++){if(prop['chart.labels.position']=='top'){var x=this.width*(i/this.scale2.labels.length)+this.gutterLeft+(this.width/this.scale2.labels.length);var y=this.gutterTop-6;var valign='bottom';}else{var x=this.width*(i/this.scale2.labels.length)+this.gutterLeft+(this.width/this.scale2.labels.length);var y=this.height+this.gutterTop+4;var valign='top';}
|
40
|
+
RG.text2(this,{'font':font,'size':size,'x':x+offsetx,'y':y+offsety,'text':this.scale2.labels[i],'valign':valign,'halign':'center','tag':'scale'});}
|
41
|
+
if(prop['chart.tickmarks.zerostart']){if(prop['chart.labels.position']=='top'){RG.text2(this,{'font':font,'size':size,'x':this.gutterLeft+offsetx,'y':this.gutterTop-6+offsety,'text':prop['chart.units.pre']+Number(this.min).toFixed(this.min>0?prop['chart.scale.decimals']:0)+prop['chart.units.post'],'valign':'bottom','halign':'center','tag':'scale'});}else{RG.text2(this,{'font':font,'size':size,'x':this.gutterLeft+offsetx,'y':ca.height-this.gutterBottom+5+offsety,'text':prop['chart.units.pre']+Number(this.min).toFixed(this.min>0?prop['chart.scale.decimals']:0)+prop['chart.units.post'],'valign':'top','halign':'center','tag':'scale'});}}};this.getShape=this.getBar=function(e)
|
42
|
+
{var mouseXY=RG.getMouseXY(e),mouseX=mouseXY[0],mouseY=mouseXY[1];for(var i=0,len=this.coords.length;i<len;i++){var x=this.coords[i][0],y=this.coords[i][1],w=this.coords[i][2],h=this.coords[i][3],idx=i;co.beginPath();this.drawCurvedBar({x:x,y:y,height:h,width:w});if(co.isPointInPath(mouseX,mouseY)){var tooltip=RG.parseTooltipText(prop['chart.tooltips'],idx);return{0:this,1:x,2:y,3:w,4:h,5:idx,'object':this,'x':x,'y':y,'width':w,'height':h,'index':idx,'tooltip':tooltip}}}};this.getValue=function(e)
|
43
|
+
{var mouseXY=RG.getMouseXY(e);var value=(mouseXY[0]-this.gutterLeft)/this.width;value*=this.max-this.min;value+=this.min;if(mouseXY[0]<this.gutterLeft){value=this.min;}
|
44
|
+
if(mouseXY[0]>(ca.width-this.gutterRight)){value=this.max}
|
45
|
+
return value;};this.highlight=this.Highlight=function(shape)
|
46
|
+
{var last=shape.index===this.coords.length-1;if(typeof prop['chart.highlight.style']==='function'){(prop['chart.highlight.style'])(shape);}else{this.drawCurvedBar({x:shape.x,y:shape.y,width:shape.width,height:shape.height,stroke:prop['chart.highlight.stroke'],fill:prop['chart.highlight.fill']});}};this.getObjectByXY=function(e)
|
47
|
+
{var mouseXY=RG.getMouseXY(e);if(mouseXY[0]>this.gutterLeft&&mouseXY[0]<(ca.width-this.gutterRight)&&mouseXY[1]>this.gutterTop&&mouseXY[1]<(ca.height-this.gutterBottom)){return this;}};this.adjusting_mousemove=this.Adjusting_mousemove=function(e)
|
48
|
+
{if(prop['chart.adjustable']&&RG.Registry.Get('chart.adjusting')&&RG.Registry.Get('chart.adjusting').uid==this.uid){var mouseXY=RG.getMouseXY(e);var value=this.getValue(e);if(typeof(value)=='number'){this.value=Number(value.toFixed(prop['chart.scale.decimals']));RG.redrawCanvas(ca);RG.fireCustomEvent(this,'onadjust');}}};this.drawSpecificLabels=this.DrawSpecificLabels=function()
|
49
|
+
{var labels=prop['chart.labels.specific'];if(labels){var font=prop['chart.text.font'],size=prop['chart.text.size'],valign=(prop['chart.labels.position']=='top'?'bottom':'top'),step=this.width/(labels.length-1),offsetx=prop['chart.labels.offsetx'],offsety=prop['chart.labels.offsety']
|
50
|
+
co.beginPath();co.fillStyle=prop['chart.text.color'];for(var i=0;i<labels.length;++i){RG.Text2(this,{font:font,size:size,x:this.gutterLeft+(step*i)+offsetx,y:prop['chart.labels.position']=='top'?this.gutterTop-7+offsety:ca.height-this.gutterBottom+7+offsety,text:labels[i],valign:valign,halign:'center',tag:'labels.specific'});}
|
51
|
+
co.fill();}};this.getXCoord=function(value)
|
52
|
+
{var min=this.min;if(value<min||value>this.max){return null;}
|
53
|
+
var barWidth=ca.width-this.gutterLeft-this.gutterRight;var coord=((value-min)/(this.max-min))*barWidth;coord=this.gutterLeft+coord;return coord;};this.overChartArea=function(e)
|
54
|
+
{var mouseXY=RGraph.getMouseXY(e);var mouseX=mouseXY[0];var mouseY=mouseXY[1];if(mouseX>=this.gutterLeft&&mouseX<=(ca.width-this.gutterRight)&&mouseY>=this.gutterTop&&mouseY<=(ca.height-this.gutterBottom)){return true;}
|
55
|
+
return false;};this.parseColors=function()
|
56
|
+
{if(this.original_colors.length===0){this.original_colors['chart.colors']=RG.array_clone(prop['chart.colors']);this.original_colors['chart.tickmarks.color']=RG.array_clone(prop['chart.tickmarks.color']);this.original_colors['chart.strokestyle.inner']=RG.array_clone(prop['chart.strokestyle.inner']);this.original_colors['chart.strokestyle.outer']=RG.array_clone(prop['chart.strokestyle.outer']);this.original_colors['chart.highlight.fill']=RG.array_clone(prop['chart.highlight.fill']);this.original_colors['chart.highlight.stroke']=RG.array_clone(prop['chart.highlight.stroke']);this.original_colors['chart.highlight.color']=RG.array_clone(prop['chart.highlight.color']);}
|
57
|
+
var colors=prop['chart.colors'];for(var i=0;i<colors.length;++i){colors[i]=this.parseSingleColorForGradient(colors[i]);}
|
58
|
+
prop['chart.tickmarks.color']=this.parseSingleColorForGradient(prop['chart.tickmarks.color']);prop['chart.strokestyle.inner']=this.parseSingleColorForGradient(prop['chart.strokestyle.inner']);prop['chart.strokestyle.outer']=this.parseSingleColorForGradient(prop['chart.strokestyle.outer']);prop['chart.highlight.fill']=this.parseSingleColorForGradient(prop['chart.highlight.fill']);prop['chart.highlight.stroke']=this.parseSingleColorForGradient(prop['chart.highlight.stroke']);prop['chart.background.color']=this.parseSingleColorForGradient(prop['chart.background.color']);};this.reset=function()
|
59
|
+
{};this.parseSingleColorForGradient=function(color)
|
60
|
+
{if(!color||typeof(color)!='string'){return color;}
|
61
|
+
if(color.match(/^gradient\((.*)\)$/i)){var parts=RegExp.$1.split(':');var grad=co.createLinearGradient(prop['chart.gutter.left'],0,ca.width-prop['chart.gutter.right'],0);var diff=1/(parts.length-1);grad.addColorStop(0,RG.trim(parts[0]));for(var j=1;j<parts.length;++j){grad.addColorStop(j*diff,RG.trim(parts[j]));}}
|
62
|
+
return grad?grad:color;};this.drawBevel=this.DrawBevel=function()
|
63
|
+
{for(var i=0,len=0;i<this.coords.length;++i)len+=this.coords[i][2];co.save();co.beginPath();co.rect(this.coords[0][0],this.coords[0][1],len,this.coords[0][3]);co.clip();co.save();co.beginPath();this.drawCurvedBar({x:this.coords[0][0],y:this.coords[0][1],width:len,height:this.coords[0][3]});co.clip();co.beginPath();co.shadowColor='black';co.shadowOffsetX=0;co.shadowOffsetY=0;co.shadowBlur=15;co.lineWidth=2;this.drawCurvedBar({x:this.coords[0][0]-51,y:this.coords[0][1]-1,width:len+52,height:this.coords[0][3]+2});co.stroke();co.restore();co.restore();};this.drawTitle=this.DrawTitle=function()
|
64
|
+
{if(prop['chart.title'].length){var x=((ca.width-this.gutterLeft-this.gutterRight)/2)+this.gutterLeft;var text=prop['chart.title'];var size=prop['chart.title.size']?prop['chart.title.size']:prop['chart.text.size']+2;var font=prop['chart.title.font']?prop['chart.title.font']:prop['chart.text.font'];if(prop['chart.labels.position']=='top'){y=ca.height-this.gutterBottom+5;x=((ca.width-this.gutterLeft-this.gutterRight)/2)+this.gutterLeft;valign='top';}else{x=((ca.width-this.gutterLeft-this.gutterRight)/2)+this.gutterLeft;y=this.gutterTop-5;valign='bottom';}
|
65
|
+
RG.Text2(this,{'font':font,'size':size,'x':typeof(prop['chart.title.x'])=='number'?prop['chart.title.x']:x,'y':typeof(prop['chart.title.y'])=='number'?prop['chart.title.y']:y,'text':text,'valign':prop['chart.title.valign']?prop['chart.title.valign']:valign,'halign':prop['chart.title.halign']?prop['chart.title.halign']:'center','bold':prop['chart.title.bold'],'bounding':prop['chart.title.background']?true:false,'boundingFill':prop['chart.title.background'],'tag':'title'});}};this.interactiveKeyHighlight=function(index)
|
66
|
+
{var coords=this.coords[index];co.beginPath();co.strokeStyle=prop['chart.key.interactive.highlight.chart.stroke'];co.lineWidth=2;co.fillStyle=prop['chart.key.interactive.highlight.chart.fill'];co.rect(coords[0],coords[1],coords[2],coords[3]);co.fill();co.stroke();co.lineWidth=1;};this.on=function(type,func)
|
67
|
+
{if(type.substr(0,2)!=='on'){type='on'+type;}
|
68
|
+
if(typeof this[type]!=='function'){this[type]=func;}else{RG.addCustomEventListener(this,type,func);}
|
69
|
+
return this;};this.drawCurvedBar=function(opt)
|
70
|
+
{pa2(co,'b r % % % %',opt.x,opt.y,opt.width,opt.height);if(opt.stroke){co.strokeStyle=opt.stroke;co.stroke();}
|
71
|
+
if(opt.fill){co.fillStyle=opt.fill;co.fill();}}
|
72
|
+
this.firstDrawFunc=function()
|
73
|
+
{};this.grow=function()
|
74
|
+
{var obj=this;var canvas=obj.canvas;var context=obj.context;var initial_value=obj.currentValue;var opt=arguments[0]||{};var numFrames=opt.frames||30;var frame=0
|
75
|
+
var callback=arguments[1]||function(){};if(typeof obj.value==='object'){if(RG.is_null(obj.currentValue)){obj.currentValue=[];for(var i=0,len=obj.value.length;i<len;++i){obj.currentValue[i]=0;}}
|
76
|
+
var diff=[];var increment=[];for(var i=0,len=obj.value.length;i<len;++i){diff[i]=obj.value[i]-Number(obj.currentValue[i]);increment[i]=diff[i]/numFrames;}
|
77
|
+
if(initial_value==null){initial_value=[];for(var i=0,len=obj.value.length;i<len;++i){initial_value[i]=0;}}}else{var diff=obj.value-Number(obj.currentValue);var increment=diff/numFrames;}
|
78
|
+
function iterator()
|
79
|
+
{frame++;if(frame<=numFrames){if(typeof obj.value=='object'){obj.value=[];for(var i=0,len=initial_value.length;i<len;++i){obj.value[i]=initial_value[i]+(increment[i]*frame);}}else{obj.value=initial_value+(increment*frame);}
|
80
|
+
RGraph.clear(obj.canvas);RGraph.redrawCanvas(obj.canvas);RGraph.Effects.updateCanvas(iterator);}else{callback();}}
|
81
|
+
iterator();return this;};RG.att(ca);RG.Register(this);if(parseConfObjectForOptions){RG.parseObjectStyleConfig(this,conf.options);}};
|