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.
Files changed (67) hide show
  1. checksums.yaml +8 -8
  2. data/.travis.yml +0 -1
  3. data/README.md +3 -3
  4. data/lib/rgraph-rails/version.rb +1 -1
  5. data/vendor/assets/javascripts/RGraph.bar.js +239 -3764
  6. data/vendor/assets/javascripts/RGraph.bipolar.js +115 -1986
  7. data/vendor/assets/javascripts/RGraph.common.annotate.js +35 -399
  8. data/vendor/assets/javascripts/RGraph.common.context.js +30 -600
  9. data/vendor/assets/javascripts/RGraph.common.core.js +403 -5187
  10. data/vendor/assets/javascripts/RGraph.common.csv.js +19 -275
  11. data/vendor/assets/javascripts/RGraph.common.deprecated.js +35 -454
  12. data/vendor/assets/javascripts/RGraph.common.dynamic.js +84 -1189
  13. data/vendor/assets/javascripts/RGraph.common.effects.js +90 -1548
  14. data/vendor/assets/javascripts/RGraph.common.key.js +54 -755
  15. data/vendor/assets/javascripts/RGraph.common.resizing.js +37 -567
  16. data/vendor/assets/javascripts/RGraph.common.sheets.js +29 -356
  17. data/vendor/assets/javascripts/RGraph.common.tooltips.js +32 -614
  18. data/vendor/assets/javascripts/RGraph.common.zoom.js +14 -223
  19. data/vendor/assets/javascripts/RGraph.cornergauge.js +71 -0
  20. data/vendor/assets/javascripts/RGraph.drawing.background.js +35 -620
  21. data/vendor/assets/javascripts/RGraph.drawing.circle.js +35 -576
  22. data/vendor/assets/javascripts/RGraph.drawing.image.js +52 -807
  23. data/vendor/assets/javascripts/RGraph.drawing.marker1.js +41 -717
  24. data/vendor/assets/javascripts/RGraph.drawing.marker2.js +37 -668
  25. data/vendor/assets/javascripts/RGraph.drawing.marker3.js +36 -563
  26. data/vendor/assets/javascripts/RGraph.drawing.poly.js +40 -608
  27. data/vendor/assets/javascripts/RGraph.drawing.rect.js +35 -597
  28. data/vendor/assets/javascripts/RGraph.drawing.text.js +34 -642
  29. data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +50 -809
  30. data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +51 -856
  31. data/vendor/assets/javascripts/RGraph.fuel.js +58 -964
  32. data/vendor/assets/javascripts/RGraph.funnel.js +55 -984
  33. data/vendor/assets/javascripts/RGraph.gantt.js +75 -1241
  34. data/vendor/assets/javascripts/RGraph.gauge.js +87 -1397
  35. data/vendor/assets/javascripts/RGraph.hbar.js +143 -2376
  36. data/vendor/assets/javascripts/RGraph.hprogress.js +80 -1397
  37. data/vendor/assets/javascripts/RGraph.line.js +241 -4162
  38. data/vendor/assets/javascripts/RGraph.meter.js +74 -1278
  39. metadata +3 -30
  40. data/vendor/assets/images/bg.png +0 -0
  41. data/vendor/assets/images/bullet.png +0 -0
  42. data/vendor/assets/images/facebook-large.png +0 -0
  43. data/vendor/assets/images/google-plus-large.png +0 -0
  44. data/vendor/assets/images/logo.png +0 -0
  45. data/vendor/assets/images/meter-image-sd-needle.png +0 -0
  46. data/vendor/assets/images/meter-image-sd.png +0 -0
  47. data/vendor/assets/images/meter-sketch-needle.png +0 -0
  48. data/vendor/assets/images/meter-sketch.png +0 -0
  49. data/vendor/assets/images/odometer-background.png +0 -0
  50. data/vendor/assets/images/rgraph.jpg +0 -0
  51. data/vendor/assets/images/title.png +0 -0
  52. data/vendor/assets/images/twitter-large.png +0 -0
  53. data/vendor/assets/javascripts/RGraph.modaldialog.js +0 -301
  54. data/vendor/assets/javascripts/RGraph.odo.js +0 -1265
  55. data/vendor/assets/javascripts/RGraph.pie.js +0 -2272
  56. data/vendor/assets/javascripts/RGraph.radar.js +0 -1847
  57. data/vendor/assets/javascripts/RGraph.rose.js +0 -1877
  58. data/vendor/assets/javascripts/RGraph.rscatter.js +0 -1425
  59. data/vendor/assets/javascripts/RGraph.scatter.js +0 -2970
  60. data/vendor/assets/javascripts/RGraph.semicircularprogress.js +0 -1015
  61. data/vendor/assets/javascripts/RGraph.thermometer.js +0 -1129
  62. data/vendor/assets/javascripts/RGraph.vprogress.js +0 -1452
  63. data/vendor/assets/javascripts/RGraph.waterfall.js +0 -1252
  64. data/vendor/assets/javascripts/financial-data.js +0 -1067
  65. data/vendor/assets/stylesheets/ModalDialog.css +0 -90
  66. data/vendor/assets/stylesheets/animations.css +0 -3347
  67. data/vendor/assets/stylesheets/website.css +0 -446
@@ -1,669 +1,38 @@
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 starts at just 99 GBP and |
11
- * | you can read about it here: |
12
- * | |
13
- * | http://www.rgraph.net/license |
14
- * o--------------------------------------------------------------------------------o
15
- */
16
-
17
- /**
18
- * Having this here means that the RGraph libraries can be included in any order, instead of you having
19
- * to include the common core library first.
20
- */
21
1
 
22
- // Define the RGraph global variable
23
- RGraph = window.RGraph || {isRGraph: true};
24
- RGraph.Drawing = RGraph.Drawing || {};
25
-
26
- /**
27
- * The constructor. This function sets up the object. It takes the ID (the HTML attribute) of the canvas as the
28
- * first argument and the data as the second. If you need to change this, you can.
29
- *
30
- * @param string id The canvas tag ID
31
- * @param number x The X position of the label
32
- * @param number y The Y position of the label
33
- * @param number text The text used
34
- */
35
- RGraph.Drawing.Marker2 = function (conf)
36
- {
37
- /**
38
- * Allow for object config style
39
- */
40
- if ( typeof conf === 'object'
41
- && typeof conf.x === 'number'
42
- && typeof conf.y === 'number'
43
- && typeof conf.id === 'string'
44
- && typeof conf.text === 'string') {
45
-
46
- var id = conf.id
47
- var canvas = document.getElementById(id);
48
- var x = conf.x;
49
- var y = conf.y;
50
- var text = conf.text;
51
-
52
- var parseConfObjectForOptions = true; // Set this so the config is parsed (at the end of the constructor)
53
-
54
- } else {
55
-
56
- var id = conf;
57
- var canvas = document.getElementById(id);
58
- var x = arguments[1];
59
- var y = arguments[2];
60
- var text = arguments[3];
61
- }
62
-
63
-
64
-
65
-
66
- this.id = id;
67
- this.canvas = document.getElementById(this.id);
68
- this.context = this.canvas.getContext('2d')
69
- this.colorsParsed = false;
70
- this.canvas.__object__ = this;
71
- this.original_colors = [];
72
- this.firstDraw = true; // After the first draw this will be false
73
-
74
-
75
- /**
76
- * Store the properties
77
- */
78
- this.x = x;
79
- this.y = y;
80
- this.text = text;
81
-
82
-
83
- /**
84
- * This defines the type of this shape
85
- */
86
- this.type = 'drawing.marker2';
87
-
88
-
89
- /**
90
- * This facilitates easy object identification, and should always be true
91
- */
92
- this.isRGraph = true;
93
-
94
-
95
- /**
96
- * This adds a uid to the object that you can use for identification purposes
97
- */
98
- this.uid = RGraph.CreateUID();
99
-
100
-
101
- /**
102
- * This adds a UID to the canvas for identification purposes
103
- */
104
- this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.CreateUID();
105
-
106
-
107
- /**
108
- * Some example background properties
109
- */
110
- this.properties =
111
- {
112
- 'chart.strokestyle': 'black',
113
- 'chart.fillstyle': 'white',
114
- 'chart.text.color': 'black',
115
- 'chart.text.size': 12,
116
- 'chart.text.font': 'Segoe UI, Arial, Verdana, sans-serif',
117
- 'chart.text.accessible': true,
118
- 'chart.text.accessible.overflow': 'visible',
119
- 'chart.text.accessible.pointerevents': false,
120
- 'chart.events.click': null,
121
- 'chart.events.mousemove': null,
122
- 'chart.shadow': true,
123
- 'chart.shadow.color': 'gray',
124
- 'chart.shadow.offsetx': 3,
125
- 'chart.shadow.offsety': 3,
126
- 'chart.shadow.blur': 5,
127
- 'chart.highlight.stroke': 'rgba(0,0,0,0)',
128
- 'chart.highlight.fill': 'rgba(255,255,255,0.7)',
129
- 'chart.tooltips': null,
130
- 'chart.tooltips.highlight': true,
131
- 'chart.tooltips.event': 'onclick',
132
- 'chart.voffset': 20,
133
- 'chart.clearto': 'rgba(0,0,0,0)'
134
- }
135
-
136
- /**
137
- * A simple check that the browser has canvas support
138
- */
139
- if (!this.canvas) {
140
- alert('[DRAWING.MARKER2] No canvas support');
141
- return;
142
- }
143
-
144
- /**
145
- * These are used to store coords
146
- */
147
- this.coords = [];
148
- this.coordsText = [];
149
-
150
-
151
- /**
152
- * Create the dollar object so that functions can be added to them
153
- */
154
- this.$0 = {};
155
-
156
-
157
- /**
158
- * Translate half a pixel for antialiasing purposes - but only if it hasn't beeen
159
- * done already
160
- */
161
- if (!this.canvas.__rgraph_aa_translated__) {
162
- this.context.translate(0.5,0.5);
163
-
164
- this.canvas.__rgraph_aa_translated__ = true;
165
- }
166
-
167
-
168
-
169
-
170
- // Short variable names
171
- var RG = RGraph,
172
- ca = this.canvas,
173
- co = ca.getContext('2d'),
174
- prop = this.properties,
175
- pa2 = RG.path2,
176
- win = window,
177
- doc = document,
178
- ma = Math
179
-
180
-
181
-
182
- /**
183
- * "Decorate" the object with the generic effects if the effects library has been included
184
- */
185
- if (RG.Effects && typeof RG.Effects.decorate === 'function') {
186
- RG.Effects.decorate(this);
187
- }
188
-
189
-
190
-
191
-
192
- /**
193
- * A setter method for setting graph properties. It can be used like this: obj.Set('chart.strokestyle', '#666');
194
- *
195
-
196
- * @param name string The name of the property to set OR it can be a map
197
- * of name/value settings like what you set in the constructor
198
- */
199
- this.set =
200
- this.Set = function (name)
201
- {
202
- var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
203
-
204
- /**
205
- * the number of arguments is only one and it's an
206
- * object - parse it for configuration data and return.
207
- */
208
- if (arguments.length === 1 && typeof name === 'object') {
209
- RG.parseObjectStyleConfig(this, name);
210
- return this;
211
- }
212
-
213
-
214
-
215
-
216
-
217
- /**
218
- * This should be done first - prepend the propertyy name with "chart." if necessary
219
- */
220
- if (name.substr(0,6) != 'chart.') {
221
- name = 'chart.' + name;
222
- }
223
-
224
-
225
-
226
-
227
- // Convert uppercase letters to dot+lower case letter
228
- while(name.match(/([A-Z])/)) {
229
- name = name.replace(/([A-Z])/, '.' + RegExp.$1.toLowerCase());
230
- }
231
-
232
-
233
-
234
-
235
-
236
-
237
- prop[name] = value;
238
-
239
- return this;
240
- };
241
-
242
-
243
-
244
-
245
- /**
246
- * A getter method for retrieving graph properties. It can be used like this: obj.Get('chart.strokestyle');
247
- *
248
- * @param name string The name of the property to get
249
- */
250
- this.get =
251
- this.Get = function (name)
252
- {
253
- /**
254
- * This should be done first - prepend the property name with "chart." if necessary
255
- */
256
- if (name.substr(0,6) != 'chart.') {
257
- name = 'chart.' + name;
258
- }
259
-
260
- // Convert uppercase letters to dot+lower case letter
261
- name = name.replace(/([A-Z])/g, function (str)
262
- {
263
- return '.' + String(RegExp.$1).toLowerCase()
264
- });
265
-
266
- return prop[name.toLowerCase()];
267
- };
268
-
269
-
270
-
271
-
272
- /**
273
- * Draws the marker
274
- */
275
- this.draw =
276
- this.Draw = function ()
277
- {
278
- /**
279
- * Reset the linewidth
280
- */
281
- co.lineWidth = 1;
282
-
283
- /**
284
- * Fire the onbeforedraw event
285
- */
286
- RG.FireCustomEvent(this, 'onbeforedraw');
287
-
288
-
289
- this.metrics = RG.MeasureText(this.text, prop['chart.text.bold'], prop['chart.text.font'], prop['chart.text.size']);
290
-
291
-
292
-
293
- if (this.x + this.metrics[0] >= ca.width) {
294
- this.alignRight = true;
295
- }
296
-
297
-
298
-
299
-
300
- /**
301
- * Parse the colors. This allows for simple gradient syntax
302
- */
303
- if (!this.colorsParsed) {
304
-
305
- this.parseColors();
306
-
307
- // Don't want to do this again
308
- this.colorsParsed = true;
309
- }
310
-
311
-
312
-
313
-
314
- /***************
315
- * Draw the box *
316
- ****************/
317
-
318
- var x = this.alignRight ? this.x - this.metrics[0] - 6 : this.x;
319
- var y = this.y - 6 - prop['chart.voffset'] - this.metrics[1];
320
- var width = this.metrics[0] + 6;
321
- var height = this.metrics[1] + 6;
322
-
323
- // Store these coords as the coords of the label
324
- this.coords[0] = [x, y, width, height];
325
-
326
-
327
-
328
- /**
329
- * Stop this growing uncntrollably
330
- */
331
- this.coordsText = [];
332
-
333
-
334
- // Set the linewidth
335
- co.lineWidth = prop['chart.linewidth'];
336
-
337
-
338
-
339
-
340
-
341
- /**
342
- * Draw the box that the text sits in
343
- */
344
-
345
- if (prop['chart.shadow']) {
346
- RG.SetShadow(this, prop['chart.shadow.color'], prop['chart.shadow.offsetx'], prop['chart.shadow.offsety'], prop['chart.shadow.blur']);
347
- }
348
- co.strokeStyle = prop['chart.strokestyle'];
349
- co.fillStyle = prop['chart.fillstyle'];
350
-
351
- // This partcular strokeRect has 0 width and so ends up being a line
352
- co.strokeRect(x + (this.alignRight ? width : 0), y, 0, height + prop['chart.voffset'] - 6);
353
-
354
- co.strokeRect(x, y, width, height);
355
- co.fillRect(x, y, width, height);
356
-
357
- RG.NoShadow(this);
358
-
359
- co.fillStyle = prop['chart.text.color'];
360
-
361
- // Draw the text
362
- RG.text2(this, {
363
- 'font':prop['chart.text.font'],
364
- 'size':prop['chart.text.size'],
365
- 'x': ma.round(this.x) - (this.alignRight ? this.metrics[0] + 3 : -3),
366
- 'y':this.y - 3 - prop['chart.voffset'],
367
- 'text':this.text,
368
- 'valign':'bottom',
369
- 'halign':'left',
370
- 'tag': 'labels'
371
- });
372
-
373
- this.coords[0].push([x, y, width, height]);
374
-
375
-
376
-
377
-
378
-
379
-
380
-
381
-
382
- // Must turn the shadow off
383
- RG.NoShadow(this);
384
-
385
-
386
-
387
- /**
388
- * Reset the testBaseline
389
- */
390
- co.textBaseline = 'alphabetic';
391
-
392
-
393
- /**
394
- * This installs the event listeners
395
- */
396
- RG.InstallEventListeners(this);
397
-
398
-
399
- /**
400
- * Fire the onfirstdraw event
401
- */
402
- if (this.firstDraw) {
403
- RG.fireCustomEvent(this, 'onfirstdraw');
404
- this.firstDraw = false;
405
- this.firstDrawFunc();
406
- }
407
-
408
-
409
-
410
-
411
- /**
412
- * Fire the ondraw event
413
- */
414
- RG.FireCustomEvent(this, 'ondraw');
415
-
416
- return this;
417
- };
418
-
419
-
420
-
421
- /**
422
- * Used in chaining. Runs a function there and then - not waiting for
423
- * the events to fire (eg the onbeforedraw event)
424
- *
425
- * @param function func The function to execute
426
- */
427
- this.exec = function (func)
428
- {
429
- func(this);
430
-
431
- return this;
432
- };
433
-
434
-
435
-
436
-
437
- /**
438
- * The getObjectByXY() worker method
439
- */
440
- this.getObjectByXY = function (e)
441
- {
442
- var mouseXY = RG.getMouseXY(e);
443
-
444
- if (this.getShape(e)) {
445
- return this;
446
- }
447
- };
448
-
449
-
450
-
451
-
452
- /**
453
- * Not used by the class during creating the shape, but is used by event handlers
454
- * to get the coordinates (if any) of the selected bar
455
- *
456
- * @param object e The event object
457
- * @param object OPTIONAL You can pass in the bar object instead of the
458
- * function using "this"
459
- */
460
- this.getShape = function (e)
461
- {
462
- var mouseXY = RG.getMouseXY(e);
463
- var mouseX = mouseXY[0];
464
- var mouseY = mouseXY[1];
465
-
466
- if ( mouseX >= this.coords[0][0] && mouseX <= (this.coords[0][0] + this.coords[0][2]) ) {
467
-
468
- if (mouseY >= this.coords[0][1] && mouseY <= (this.coords[0][1] + this.coords[0][3])) {
469
-
470
- return {
471
- 0: this, 1: this.coords[0][0], 2: this.coords[0][1], 3: this.coords[0][2], 4: this.coords[0][3], 5: 0,
472
- 'object': this, 'x': this.coords[0][0], 'y': this.coords[0][1], 'width': this.coords[0][2], 'height': this.coords[0][3], 'index': 0, 'tooltip': prop['chart.tooltips'] ? prop['chart.tooltips'][0] : null
473
- };
474
- }
475
- }
476
-
477
- return null;
478
- };
479
-
480
-
481
-
482
-
483
- /**
484
- * This function positions a tooltip when it is displayed
485
- *
486
- * @param obj object The chart object
487
- * @param int x The X coordinate specified for the tooltip
488
- * @param int y The Y coordinate specified for the tooltip
489
- * @param object tooltip The tooltips DIV element
490
- * @param number idx The index of the tooltip
491
- */
492
- this.positionTooltip = function (obj, x, y, tooltip, idx)
493
- {
494
- var textDimensions = RG.measureText(this.text, false, prop['chart.text.font'], prop['chart.text.size']);
495
- var canvasXY = RG.getCanvasXY(obj.canvas);
496
- var mouseXY = RG.getMouseXY(window.event);
497
- var width = tooltip.offsetWidth;
498
- var height = tooltip.offsetHeight;
499
-
500
- // Set the top position
501
- tooltip.style.left = 0;
502
- tooltip.style.top = window.event.pageY - height - 5 + 'px';
503
-
504
- // By default any overflow is hidden
505
- tooltip.style.overflow = '';
506
-
507
- // Reposition the tooltip if at the edges:
508
-
509
- // LEFT edge
510
- if (canvasXY[0] + mouseXY[0] - (width / 2) < 0) {
511
- tooltip.style.left = canvasXY[0] + mouseXY[0] - (width * 0.1) + 'px';
512
-
513
- // RIGHT edge
514
- } else if (canvasXY[0] + mouseXY[0] + (width / 2) > doc.body.offsetWidth) {
515
- tooltip.style.left = canvasXY[0] + mouseXY[0] - (width * 0.9) + 'px';
516
-
517
- // Default positioning - CENTERED
518
- } else {
519
- tooltip.style.left = canvasXY[0] + mouseXY[0] - (width / 2) + 'px';
520
- }
521
- };
522
-
523
-
524
-
525
-
526
- /**
527
- * Each object type has its own Highlight() function which highlights the appropriate shape
528
- *
529
- * @param object shape The shape to highlight
530
- */
531
- this.highlight =
532
- this.Highlight = function (shape)
533
- {
534
- if (prop['chart.tooltips.highlight']) {
535
- if (typeof prop['chart.highlight.style'] === 'function') {
536
- (prop['chart.highlight.style'])(shape);
537
- } else {
538
- pa2(co, ['b','r',this.coords[0][0],this.coords[0][1],this.coords[0][2],this.coords[0][3],'f',prop['chart.highlight.fill'],'s',prop['chart.highlight.stroke']]);
539
- }
540
- }
541
- };
542
-
543
-
544
-
545
-
546
- /**
547
- * This allows for easy specification of gradients
548
- */
549
- this.parseColors = function ()
550
- {
551
- // Save the original colors so that they can be restored when the canvas is reset
552
- if (this.original_colors.length === 0) {
553
- this.original_colors['chart.fillstyle'] = RG.array_clone(prop['chart.fillstyle']);
554
- this.original_colors['chart.strokestyle'] = RG.array_clone(prop['chart.strokestyle']);
555
- this.original_colors['chart.highlight.fill'] = RG.array_clone(prop['chart.highlight.fill']);
556
- this.original_colors['chart.highlight.stroke'] = RG.array_clone(prop['chart.highlight.stroke']);
557
- this.original_colors['chart.text.color'] = RG.array_clone(prop['chart.text.color']);
558
- }
559
-
560
-
561
-
562
-
563
- /**
564
- * Parse various properties for colors
565
- */
566
- prop['chart.fillstyle'] = this.parseSingleColorForGradient(prop['chart.fillstyle']);
567
- prop['chart.strokestyle'] = this.parseSingleColorForGradient(prop['chart.strokestyle']);
568
- prop['chart.highlight.stroke'] = this.parseSingleColorForGradient(prop['chart.highlight.stroke']);
569
- prop['chart.highlight.fill'] = this.parseSingleColorForGradient(prop['chart.highlight.fill']);
570
- prop['chart.text.color'] = this.parseSingleColorForGradient(prop['chart.text.color']);
571
- };
572
-
573
-
574
-
575
-
576
- /**
577
- * Use this function to reset the object to the post-constructor state. Eg reset colors if
578
- * need be etc
579
- */
580
- this.reset = function ()
581
- {
582
- };
583
-
584
-
585
-
586
-
587
- /**
588
- * This parses a single color value
589
- */
590
- this.parseSingleColorForGradient = function (color)
591
- {
592
- var canvas = this.canvas;
593
- var context = this.context;
594
-
595
- if (!color) {
596
- return color;
597
- }
598
-
599
- if (typeof color === 'string' && color.match(/^gradient\((.*)\)$/i)) {
600
-
601
- var parts = RegExp.$1.split(':');
602
-
603
- // Create the gradient
604
- var grad = co.createLinearGradient(this.x, this.y, this.x + this.metrics[0], this.y);
605
-
606
- var diff = 1 / (parts.length - 1);
607
-
608
- grad.addColorStop(0, RG.trim(parts[0]));
609
-
610
- for (var j=1; j<parts.length; ++j) {
611
- grad.addColorStop(j * diff, RG.trim(parts[j]));
612
- }
613
- }
614
-
615
- return grad ? grad : color;
616
- };
617
-
618
-
619
-
620
-
621
- /**
622
- * Using a function to add events makes it easier to facilitate method chaining
623
- *
624
- * @param string type The type of even to add
625
- * @param function func
626
- */
627
- this.on = function (type, func)
628
- {
629
- if (type.substr(0,2) !== 'on') {
630
- type = 'on' + type;
631
- }
632
-
633
- this[type] = func;
634
-
635
- return this;
636
- };
637
-
638
-
639
-
640
-
641
- /**
642
- * This function runs once only
643
- * (put at the end of the file (before any effects))
644
- */
645
- this.firstDrawFunc = function ()
646
- {
647
- };
648
-
649
-
650
- RG.att(ca);
651
-
652
-
653
-
654
- /**
655
- * Objects are now always registered so that the chart is redrawn if need be.
656
- */
657
- RG.Register(this);
658
-
659
-
660
-
661
-
662
- /**
663
- * the number of arguments is only one and it's an
664
- * object - parse it for configuration data and return.
665
- */
666
- if (parseConfObjectForOptions) {
667
- RG.parseObjectStyleConfig(this, conf.options);
668
- }
669
- };
2
+ RGraph=window.RGraph||{isRGraph:true};RGraph.Drawing=RGraph.Drawing||{};RGraph.Drawing.Marker2=function(conf)
3
+ {if(typeof conf==='object'&&typeof conf.x==='number'&&typeof conf.y==='number'&&typeof conf.id==='string'&&typeof conf.text==='string'){var id=conf.id
4
+ var canvas=document.getElementById(id);var x=conf.x;var y=conf.y;var text=conf.text;var parseConfObjectForOptions=true;}else{var id=conf;var canvas=document.getElementById(id);var x=arguments[1];var y=arguments[2];var text=arguments[3];}
5
+ this.id=id;this.canvas=document.getElementById(this.id);this.context=this.canvas.getContext('2d')
6
+ this.colorsParsed=false;this.canvas.__object__=this;this.original_colors=[];this.firstDraw=true;this.x=x;this.y=y;this.text=text;this.type='drawing.marker2';this.isRGraph=true;this.uid=RGraph.CreateUID();this.canvas.uid=this.canvas.uid?this.canvas.uid:RGraph.CreateUID();this.properties={'chart.strokestyle':'black','chart.fillstyle':'white','chart.text.color':'black','chart.text.size':12,'chart.text.font':'Segoe UI, Arial, Verdana, sans-serif','chart.text.accessible':true,'chart.text.accessible.overflow':'visible','chart.text.accessible.pointerevents':true,'chart.events.click':null,'chart.events.mousemove':null,'chart.shadow':true,'chart.shadow.color':'gray','chart.shadow.offsetx':3,'chart.shadow.offsety':3,'chart.shadow.blur':5,'chart.highlight.stroke':'rgba(0,0,0,0)','chart.highlight.fill':'rgba(255,255,255,0.7)','chart.tooltips':null,'chart.tooltips.highlight':true,'chart.tooltips.event':'onclick','chart.voffset':20,'chart.clearto':'rgba(0,0,0,0)'}
7
+ if(!this.canvas){alert('[DRAWING.MARKER2] No canvas support');return;}
8
+ this.coords=[];this.coordsText=[];this.$0={};if(!this.canvas.__rgraph_aa_translated__){this.context.translate(0.5,0.5);this.canvas.__rgraph_aa_translated__=true;}
9
+ var RG=RGraph,ca=this.canvas,co=ca.getContext('2d'),prop=this.properties,pa2=RG.path2,win=window,doc=document,ma=Math
10
+ if(RG.Effects&&typeof RG.Effects.decorate==='function'){RG.Effects.decorate(this);}
11
+ this.set=this.Set=function(name)
12
+ {var value=typeof arguments[1]==='undefined'?null:arguments[1];if(arguments.length===1&&typeof name==='object'){RG.parseObjectStyleConfig(this,name);return this;}
13
+ if(name.substr(0,6)!='chart.'){name='chart.'+name;}
14
+ while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
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
+ {co.lineWidth=1;RG.FireCustomEvent(this,'onbeforedraw');this.metrics=RG.MeasureText(this.text,prop['chart.text.bold'],prop['chart.text.font'],prop['chart.text.size']);if(this.x+this.metrics[0]>=ca.width){this.alignRight=true;}
20
+ if(!this.colorsParsed){this.parseColors();this.colorsParsed=true;}
21
+ var x=this.alignRight?this.x-this.metrics[0]-6:this.x;var y=this.y-6-prop['chart.voffset']-this.metrics[1];var width=this.metrics[0]+6;var height=this.metrics[1]+6;this.coords[0]=[x,y,width,height];this.coordsText=[];co.lineWidth=prop['chart.linewidth'];if(prop['chart.shadow']){RG.SetShadow(this,prop['chart.shadow.color'],prop['chart.shadow.offsetx'],prop['chart.shadow.offsety'],prop['chart.shadow.blur']);}
22
+ co.strokeStyle=prop['chart.strokestyle'];co.fillStyle=prop['chart.fillstyle'];co.strokeRect(x+(this.alignRight?width:0),y,0,height+prop['chart.voffset']-6);co.strokeRect(x,y,width,height);co.fillRect(x,y,width,height);RG.NoShadow(this);co.fillStyle=prop['chart.text.color'];RG.text2(this,{'font':prop['chart.text.font'],'size':prop['chart.text.size'],'x':ma.round(this.x)-(this.alignRight?this.metrics[0]+3:-3),'y':this.y-3-prop['chart.voffset'],'text':this.text,'valign':'bottom','halign':'left','tag':'labels'});this.coords[0].push([x,y,width,height]);RG.NoShadow(this);co.textBaseline='alphabetic';RG.InstallEventListeners(this);if(this.firstDraw){RG.fireCustomEvent(this,'onfirstdraw');this.firstDraw=false;this.firstDrawFunc();}
23
+ RG.FireCustomEvent(this,'ondraw');return this;};this.exec=function(func)
24
+ {func(this);return this;};this.getObjectByXY=function(e)
25
+ {var mouseXY=RG.getMouseXY(e);if(this.getShape(e)){return this;}};this.getShape=function(e)
26
+ {var mouseXY=RG.getMouseXY(e);var mouseX=mouseXY[0];var mouseY=mouseXY[1];if(mouseX>=this.coords[0][0]&&mouseX<=(this.coords[0][0]+this.coords[0][2])){if(mouseY>=this.coords[0][1]&&mouseY<=(this.coords[0][1]+this.coords[0][3])){return{0:this,1:this.coords[0][0],2:this.coords[0][1],3:this.coords[0][2],4:this.coords[0][3],5:0,'object':this,'x':this.coords[0][0],'y':this.coords[0][1],'width':this.coords[0][2],'height':this.coords[0][3],'index':0,'tooltip':prop['chart.tooltips']?prop['chart.tooltips'][0]:null};}}
27
+ return null;};this.highlight=this.Highlight=function(shape)
28
+ {if(prop['chart.tooltips.highlight']){if(typeof prop['chart.highlight.style']==='function'){(prop['chart.highlight.style'])(shape);}else{pa2(co,['b','r',this.coords[0][0],this.coords[0][1],this.coords[0][2],this.coords[0][3],'f',prop['chart.highlight.fill'],'s',prop['chart.highlight.stroke']]);}}};this.parseColors=function()
29
+ {if(this.original_colors.length===0){this.original_colors['chart.fillstyle']=RG.array_clone(prop['chart.fillstyle']);this.original_colors['chart.strokestyle']=RG.array_clone(prop['chart.strokestyle']);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.text.color']=RG.array_clone(prop['chart.text.color']);}
30
+ prop['chart.fillstyle']=this.parseSingleColorForGradient(prop['chart.fillstyle']);prop['chart.strokestyle']=this.parseSingleColorForGradient(prop['chart.strokestyle']);prop['chart.highlight.stroke']=this.parseSingleColorForGradient(prop['chart.highlight.stroke']);prop['chart.highlight.fill']=this.parseSingleColorForGradient(prop['chart.highlight.fill']);prop['chart.text.color']=this.parseSingleColorForGradient(prop['chart.text.color']);};this.reset=function()
31
+ {};this.parseSingleColorForGradient=function(color)
32
+ {var canvas=this.canvas;var context=this.context;if(!color){return color;}
33
+ if(typeof color==='string'&&color.match(/^gradient\((.*)\)$/i)){var parts=RegExp.$1.split(':');var grad=co.createLinearGradient(this.x,this.y,this.x+this.metrics[0],this.y);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]));}}
34
+ return grad?grad:color;};this.on=function(type,func)
35
+ {if(type.substr(0,2)!=='on'){type='on'+type;}
36
+ if(typeof this[type]!=='function'){this[type]=func;}else{RG.addCustomEventListener(this,type,func);}
37
+ return this;};this.firstDrawFunc=function()
38
+ {};RG.att(ca);RG.Register(this);if(parseConfObjectForOptions){RG.parseObjectStyleConfig(this,conf.options);}};