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