rgraph-rails 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,718 +1,42 @@
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 - should be a single character (unless you've significantly increased
34
- * the size of the marker.
35
- */
36
- RGraph.Drawing.Marker1 = function (conf)
37
- {
38
- /**
39
- * Allow for object config style
40
- */
41
- if ( typeof conf === 'object'
42
- && typeof conf.x === 'number'
43
- && typeof conf.y === 'number'
44
- && typeof conf.radius == 'number'
45
- && typeof conf.id === 'string'
46
- && typeof conf.text === 'string') {
47
-
48
- var id = conf.id
49
- var canvas = document.getElementById(id);
50
- var x = conf.x;
51
- var y = conf.y;
52
- var radius = conf.radius;
53
- var text = conf.text;
54
- var parseConfObjectForOptions = true; // Set this so the config is parsed (at the end of the constructor)
55
-
56
- } else {
57
-
58
- var id = conf;
59
- var canvas = document.getElementById(id);
60
- var x = arguments[1];
61
- var y = arguments[2];
62
- var radius = arguments[3];
63
- var text = arguments[4];
64
- }
65
-
66
-
67
-
68
-
69
- // id, x, y, radius, text)
70
- this.id = id;
71
- this.canvas = canvas;
72
- this.context = this.canvas.getContext("2d");
73
- this.colorsParsed = false;
74
- this.canvas.__object__ = this;
75
- this.original_colors = [];
76
- this.firstDraw = true; // After the first draw this will be false
77
-
78
-
79
- /**
80
- * Store the properties
81
- */
82
- this.centerx = x;
83
- this.centery = y;
84
- this.radius = radius;
85
- this.text = text;
86
-
87
-
88
- /**
89
- * This defines the type of this shape
90
- */
91
- this.type = 'drawing.marker1';
92
-
93
-
94
- /**
95
- * This facilitates easy object identification, and should always be true
96
- */
97
- this.isRGraph = true;
98
-
99
-
100
- /**
101
- * This adds a uid to the object that you can use for identification purposes
102
- */
103
- this.uid = RGraph.CreateUID();
104
-
105
-
106
- /**
107
- * This adds a UID to the canvas for identification purposes
108
- */
109
- this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.CreateUID();
110
-
111
-
112
- /**
113
- * Some example background properties
114
- */
115
- this.properties =
116
- {
117
- 'chart.strokestyle': 'black',
118
- 'chart.fillstyle': 'white',
119
- 'chart.linewidth': 2,
120
- 'chart.text.color': 'black',
121
- 'chart.text.size': 12,
122
- 'chart.text.font': 'Segoe UI, Arial, Verdana, sans-serif',
123
- 'chart.text.accessible': true,
124
- 'chart.text.accessible.overflow': 'visible',
125
- 'chart.text.accessible.pointerevents': false,
126
- 'chart.events.click': null,
127
- 'chart.events.mousemove': null,
128
- 'chart.shadow': true,
129
- 'chart.shadow.color': '#aaa',
130
- 'chart.shadow.offsetx': 0,
131
- 'chart.shadow.offsety': 0,
132
- 'chart.shadow.blur': 15,
133
- 'chart.highlight.stroke': 'rgba(0,0,0,0)',
134
- 'chart.highlight.fill': 'rgba(255,0,0,0.7)',
135
- 'chart.tooltips': null,
136
- 'chart.tooltips.highlight': true,
137
- 'chart.tooltips.event': 'onclick',
138
- 'chart.align': 'center',
139
- 'chart.clearto': 'rgba(0,0,0,0)'
140
- }
141
-
142
- /**
143
- * A simple check that the browser has canvas support
144
- */
145
- if (!this.canvas) {
146
- alert('[DRAWING.MARKER1] No canvas support');
147
- return;
148
- }
149
-
150
-
151
- /**
152
- * Create the dollar object so that functions can be added to them
153
- */
154
- this.$0 = {};
155
-
156
-
157
- /**
158
- * Arrays that store the coordinates
159
- */
160
- this.coords = [];
161
- this.coordsText = [];
162
-
163
-
164
-
165
- /**
166
- * Translate half a pixel for antialiasing purposes - but only if it hasn't beeen
167
- * done already
168
- */
169
- if (!this.canvas.__rgraph_aa_translated__) {
170
- this.context.translate(0.5,0.5);
171
-
172
- this.canvas.__rgraph_aa_translated__ = true;
173
- }
174
-
175
-
176
-
177
-
178
-
179
- // Short variable names
180
- var RG = RGraph,
181
- ca = this.canvas,
182
- co = ca.getContext('2d'),
183
- prop = this.properties,
184
- pa2 = RG.path2,
185
- win = window,
186
- doc = document,
187
- ma = Math
188
-
189
-
190
-
191
- /**
192
- * "Decorate" the object with the generic effects if the effects library has been included
193
- */
194
- if (RG.Effects && typeof RG.Effects.decorate === 'function') {
195
- RG.Effects.decorate(this);
196
- }
197
-
198
-
199
-
200
-
201
- /**
202
- * A setter method for setting graph properties. It can be used like this: obj.Set('chart.strokestyle', '#666');
203
- *
204
- * @param name string The name of the property to set
205
- * @param value mixed The value of the property
206
- */
207
- this.set =
208
- this.Set = function (name)
209
- {
210
- var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
211
-
212
- /**
213
- * the number of arguments is only one and it's an
214
- * object - parse it for configuration data and return.
215
- */
216
- if (arguments.length === 1 && typeof name === 'object') {
217
- RG.parseObjectStyleConfig(this, name);
218
- return this;
219
- }
220
-
221
-
222
-
223
-
224
-
225
- /**
226
- * This should be done first - prepend the propertyy name with "chart." if necessary
227
- */
228
- if (name.substr(0,6) != 'chart.') {
229
- name = 'chart.' + name;
230
- }
231
-
232
-
233
-
234
-
235
- // Convert uppercase letters to dot+lower case letter
236
- while(name.match(/([A-Z])/)) {
237
- name = name.replace(/([A-Z])/, '.' + RegExp.$1.toLowerCase());
238
- }
239
-
240
-
241
-
242
-
243
-
244
-
245
- prop[name] = value;
246
-
247
- return this;
248
- };
249
-
250
-
251
-
252
-
253
- /**
254
- * A getter method for retrieving graph properties. It can be used like this: obj.Get('chart.strokestyle');
255
- *
256
- * @param name string The name of the property to get
257
- */
258
- this.get =
259
- this.Get = function (name)
260
- {
261
- /**
262
- * This should be done first - prepend the property name with "chart." if necessary
263
- */
264
- if (name.substr(0,6) != 'chart.') {
265
- name = 'chart.' + name;
266
- }
267
-
268
- // Convert uppercase letters to dot+lower case letter
269
- name = name.replace(/([A-Z])/g, function (str)
270
- {
271
- return '.' + String(RegExp.$1).toLowerCase()
272
- });
273
-
274
- return prop[name.toLowerCase()];
275
- };
276
-
277
-
278
-
279
-
280
- /**
281
- * Draws the circle
282
- */
283
- this.draw =
284
- this.Draw = function ()
285
- {
286
- /**
287
- * Fire the onbeforedraw event
288
- */
289
- RG.FireCustomEvent(this, 'onbeforedraw');
290
-
291
- var r = this.radius;
292
-
293
- if (prop['chart.align'] == 'left') {
294
-
295
- this.markerCenterx = this.centerx - r - r - 3;
296
- this.markerCentery = this.centery - r - r - 3;
297
-
298
- } else if (prop['chart.align'] == 'right') {
299
-
300
- this.markerCenterx = this.centerx + r + r + 3;
301
- this.markerCentery = this.centery - r - r - 3;
302
-
303
- } else {
304
-
305
- this.markerCenterx = this.centerx;
306
- this.markerCentery = this.centery - r - r - 3;
307
- }
308
-
309
- /**
310
- * Parse the colors. This allows for simple gradient syntax
311
- */
312
- if (!this.colorsParsed) {
313
-
314
- this.parseColors();
315
-
316
- // Don't want to do this again
317
- this.colorsParsed = true;
318
- }
319
-
320
-
321
-
322
- /**
323
- * Stop this growing uncontrollably
324
- */
325
- this.coordsText = [];
326
-
327
-
328
-
329
-
330
- /**
331
- * DRAW THE MARKER HERE
332
- */
333
- pa2(co, ['b','lw',prop['chart.linewidth']]);
334
-
335
- if (prop['chart.shadow']) {
336
- RG.SetShadow(this, prop['chart.shadow.color'], prop['chart.shadow.offsetx'], prop['chart.shadow.offsety'], prop['chart.shadow.blur']);
337
- }
338
- this.DrawMarker();
339
-
340
- pa2(co, ['c','s',prop['chart.strokestyle'],'f',prop['chart.fillstyle']]);
341
-
342
-
343
-
344
-
345
- // Turn the shadow off
346
- RG.NoShadow(this);
347
-
348
-
349
-
350
-
351
- // Now draw the text on the marker
352
- co.fillStyle = prop['chart.text.color'];
353
-
354
- // Draw the text on the marker
355
- RG.Text2(this, {'font':prop['chart.text.font'],
356
- 'size':prop['chart.text.size'],
357
- 'x':this.coords[0][0] - 1,
358
- 'y':this.coords[0][1] - 1,
359
- 'text':this.text,
360
- 'valign':'center',
361
- 'halign':'center',
362
- 'tag': 'labels'
363
- });
364
-
365
- /**
366
- * This installs the event listeners
367
- */
368
- RG.InstallEventListeners(this);
369
-
370
-
371
- /**
372
- * Fire the onfirstdraw event
373
- */
374
- if (this.firstDraw) {
375
- RG.fireCustomEvent(this, 'onfirstdraw');
376
- this.firstDraw = false;
377
- this.firstDrawFunc();
378
- }
379
-
380
-
381
-
382
-
383
- /**
384
- * Fire the ondraw event
385
- */
386
- RG.FireCustomEvent(this, 'ondraw');
387
-
388
- return this;
389
- };
390
-
391
-
392
-
393
- /**
394
- * Used in chaining. Runs a function there and then - not waiting for
395
- * the events to fire (eg the onbeforedraw event)
396
- *
397
- * @param function func The function to execute
398
- */
399
- this.exec = function (func)
400
- {
401
- func(this);
402
-
403
- return this;
404
- };
405
-
406
-
407
-
408
-
409
- /**
410
- * The getObjectByXY() worker method
411
- */
412
- this.getObjectByXY = function (e)
413
- {
414
- if (this.getShape(e)) {
415
- return this;
416
- }
417
- };
418
-
419
-
420
-
421
-
422
- /**
423
- * Not used by the class during creating the shape, but is used by event handlers
424
- * to get the coordinates (if any) of the selected bar
425
- *
426
- * @param object e The event object
427
- * @param object OPTIONAL You can pass in the bar object instead of the
428
- * function using "this"
429
- */
430
- this.getShape = function (e)
431
- {
432
- var mouseXY = RG.getMouseXY(e);
433
- var mouseX = mouseXY[0];
434
- var mouseY = mouseXY[1];
435
-
436
- /**
437
- * Path the marker but DON'T STROKE OR FILL it
438
- */
439
- co.beginPath();
440
- this.DrawMarker();
441
-
442
- if (co.isPointInPath(mouseXY[0], mouseXY[1])) {
443
-
444
- return {
445
- 0: this, 1: this.coords[0][0], 2: this.coords[0][1], 3: this.coords[0][2], 4: 0,
446
- 'object': this, 'x': this.coords[0][0], 'y': this.coords[0][1], 'radius': this.coords[0][2], 'index': 0, 'tooltip': prop['chart.tooltips'] ? prop['chart.tooltips'][0] : null
447
- };
448
- }
449
-
450
- return null;
451
- };
452
-
453
-
454
-
455
-
456
- /**
457
- * This function positions a tooltip when it is displayed
458
- *
459
- * @param obj object The chart object
460
- * @param int x The X coordinate specified for the tooltip
461
- * @param int y The Y coordinate specified for the tooltip
462
- * @param object tooltip The tooltips DIV element
463
- * @param number idx The index of the tooltip
464
- */
465
- this.positionTooltip = function (obj, x, y, tooltip, idx)
466
- {
467
- var canvasXY = RG.getCanvasXY(obj.canvas);
468
- var mouseXY = RG.getMouseXY(window.event);
469
- var width = tooltip.offsetWidth;
470
- var height = tooltip.offsetHeight;
471
-
472
- // Set the top position
473
- tooltip.style.left = 0;
474
- tooltip.style.top = canvasXY[1] + this.coords[0][1] - (height / 2) - this.radius + 'px';
475
-
476
- // Set the top position
477
- tooltip.style.left = 0;
478
- tooltip.style.top = window.event.pageY - height - 5 + 'px';
479
-
480
- // By default any overflow is hidden
481
- tooltip.style.overflow = '';
482
-
483
- // Reposition the tooltip if at the edges:
484
-
485
- // LEFT edge
486
- if (canvasXY[0] + mouseXY[0] - (width / 2) < 0) {
487
- tooltip.style.left = canvasXY[0] + mouseXY[0] - (width * 0.1) + 'px';
488
-
489
- // RIGHT edge
490
- } else if (canvasXY[0] + mouseXY[0] + (width / 2) > doc.body.offsetWidth) {
491
- tooltip.style.left = canvasXY[0] + mouseXY[0] - (width * 0.9) + 'px';
492
-
493
- // Default positioning - CENTERED
494
- } else {
495
- tooltip.style.left = canvasXY[0] + mouseXY[0] - (width / 2) + 'px';
496
- }
497
- };
498
-
499
-
500
-
501
-
502
- /**
503
- * Each object type has its own Highlight() function which highlights the appropriate shape
504
- *
505
- * @param object shape The shape to highlight
506
- */
507
- this.highlight =
508
- this.Highlight = function (shape)
509
- {
510
- if (prop['chart.tooltips.highlight']) {
511
- if (typeof prop['chart.highlight.style'] === 'function') {
512
- (prop['chart.highlight.style'])(shape);
513
- } else {
514
-
515
- co.beginPath();
516
- co.strokeStyle = prop['chart.highlight.stroke'];
517
- co.fillStyle = prop['chart.highlight.fill'];
518
- this.drawMarker();
519
- co.closePath();
520
- co.stroke();
521
- co.fill();
522
- }
523
- }
524
- };
525
-
526
-
527
-
528
-
529
- /**
530
- * This function is used to encapsulate the actual drawing of the marker. It
531
- * intentional does not start a path or set colors.
532
- */
533
- this.drawMarker =
534
- this.DrawMarker = function ()
535
- {
536
- var r = this.radius;
537
-
538
- if (prop['chart.align'] == 'left') {
539
-
540
- var x = this.markerCenterx;
541
- var y = this.markerCentery;
542
-
543
- pa2(co, ['a',x,y,r,RG.HALFPI,RG.TWOPI,false]);
544
-
545
- // special case for MSIE 7/8
546
- if (RG.ISOLD) {
547
- pa2(co,['m',x + r + r,y+r+r,'qc',x + r,y + r,x + r + 1,y,'m',x + r + r,y+r+r]);
548
- } else {
549
- pa2(co, ['qc',x + r,y + r,x + r + r,y + r + r]);
550
- }
551
-
552
- pa2(co, ['qc',x + r,y + r,x,y + r + (RG.ISOLD ? 1 : 0)]);
553
-
554
- } else if (prop['chart.align'] == 'right') {
555
-
556
- var x = this.markerCenterx;
557
- var y = this.markerCentery;
558
-
559
- pa2(co, ['a',x,y,r,RG.HALFPI,RG.PI,true]);
560
-
561
- // special case for MSIE 7/8
562
- if (RG.ISOLD) {
563
- pa2(co, ['m',x - r - r,y+r+r,'qc',x - r,y + r,x - r - 1,y,'m',x - r - r,y+r+r]);
564
- } else {
565
- pa2(co, ['qc',x - r,y + r,x - r - r,y + r + r]);
566
- }
567
-
568
- pa2(co, ['qc',x - r, y + r, x, y + r + (RG.ISOLD ? 1 : 0)]);
569
-
570
- // Default is center
571
- } else {
572
-
573
- var x = this.markerCenterx;
574
- var y = this.markerCentery;
575
-
576
- pa2(co, ['a',x, y, r, RG.HALFPI / 2, RG.PI - (RG.HALFPI / 2), true]);
577
- //co.arc(x, y, r, HALFPI / 2, PI - (HALFPI / 2), true);
578
-
579
- // special case for MSIE 7/8
580
- if (RG.ISOLD) {
581
- pa2(co, ['m',x,y+r+r-2,'qc',x,y + r + (r / 4),x - (Math.cos(RG.HALFPI / 2) * r),y + (Math.sin(RG.HALFPI / 2) * r),'m',x, y+r+r-2]);
582
- } else {
583
- pa2(co, ['qc',x,y + r + (r / 4),x,y + r + r - 2]);
584
- }
585
-
586
- pa2(co, ['qc',x,y + r + (r / 4),x + (Math.cos(RG.HALFPI / 2) * r),y + (Math.sin(RG.HALFPI / 2) * r)]);
587
- }
588
-
589
- this.coords[0] = [x, y, r];
590
- };
591
-
592
-
593
-
594
-
595
- /**
596
- * This allows for easy specification of gradients
597
- */
598
- this.parseColors = function ()
599
- {
600
-
601
- // Save the original colors so that they can be restored when the canvas is reset
602
- if (this.original_colors.length === 0) {
603
- this.original_colors['chart.fillstyle'] = RG.array_clone(prop['chart.fillstyle']);
604
- this.original_colors['chart.strokestyle'] = RG.array_clone(prop['chart.strokestyle']);
605
- this.original_colors['chart.highlight.fill'] = RG.array_clone(prop['chart.highlight.fill']);
606
- this.original_colors['chart.highlight.stroke'] = RG.array_clone(prop['chart.highlight.stroke']);
607
- this.original_colors['chart.text.color'] = RG.array_clone(prop['chart.text.color']);
608
- }
609
-
610
-
611
-
612
-
613
- /**
614
- * Parse various properties for colors
615
- */
616
- prop['chart.fillstyle'] = this.parseSingleColorForGradient(prop['chart.fillstyle']);
617
- prop['chart.strokestyle'] = this.parseSingleColorForGradient(prop['chart.strokestyle']);
618
- prop['chart.highlight.stroke'] = this.parseSingleColorForGradient(prop['chart.highlight.stroke']);
619
- prop['chart.highlight.fill'] = this.parseSingleColorForGradient(prop['chart.highlight.fill']);
620
- prop['chart.text.color'] = this.parseSingleColorForGradient(prop['chart.text.color']);
621
- };
622
-
623
-
624
-
625
-
626
- /**
627
- * Use this function to reset the object to the post-constructor state. Eg reset colors if
628
- * need be etc
629
- */
630
- this.reset = function ()
631
- {
632
- };
633
-
634
-
635
-
636
-
637
- /**
638
- * This parses a single color value
639
- */
640
- this.parseSingleColorForGradient = function (color)
641
- {
642
- if (!color || typeof(color) != 'string') {
643
- return color;
644
- }
645
-
646
- if (color.match(/^gradient\((.*)\)$/i)) {
647
-
648
- var parts = RegExp.$1.split(':');
649
-
650
- // Create the gradient
651
- var grad = co.createRadialGradient(this.markerCenterx, this.markerCentery, 0, this.markerCenterx, this.markerCentery, this.radius);
652
-
653
- var diff = 1 / (parts.length - 1);
654
-
655
- grad.addColorStop(0, RG.trim(parts[0]));
656
-
657
- for (var j=1; j<parts.length; ++j) {
658
- grad.addColorStop(j * diff, RG.trim(parts[j]));
659
- }
660
- }
661
-
662
- return grad ? grad : color;
663
- };
664
-
665
-
666
-
667
-
668
- /**
669
- * Using a function to add events makes it easier to facilitate method chaining
670
- *
671
- * @param string type The type of even to add
672
- * @param function func
673
- */
674
- this.on = function (type, func)
675
- {
676
- if (type.substr(0,2) !== 'on') {
677
- type = 'on' + type;
678
- }
679
-
680
- this[type] = func;
681
-
682
- return this;
683
- };
684
-
685
-
686
-
687
-
688
- /**
689
- * This function runs once only
690
- * (put at the end of the file (before any effects))
691
- */
692
- this.firstDrawFunc = function ()
693
- {
694
- };
695
-
696
-
697
-
698
-
699
- RG.att(ca);
700
-
701
-
702
-
703
- /**
704
- * Objects are now always registered so that the chart is redrawn if need be.
705
- */
706
- RG.Register(this);
707
-
708
-
709
-
710
-
711
- /**
712
- * This is the 'end' of the constructor so if the first argument
713
- * contains configuration data - handle that.
714
- */
715
- if (parseConfObjectForOptions) {
716
- RG.parseObjectStyleConfig(this, conf.options);
717
- }
718
- };
2
+ RGraph=window.RGraph||{isRGraph:true};RGraph.Drawing=RGraph.Drawing||{};RGraph.Drawing.Marker1=function(conf)
3
+ {if(typeof conf==='object'&&typeof conf.x==='number'&&typeof conf.y==='number'&&typeof conf.radius=='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 radius=conf.radius;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 radius=arguments[3];var text=arguments[4];}
5
+ this.id=id;this.canvas=canvas;this.context=this.canvas.getContext("2d");this.colorsParsed=false;this.canvas.__object__=this;this.original_colors=[];this.firstDraw=true;this.centerx=x;this.centery=y;this.radius=radius;this.text=text;this.type='drawing.marker1';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.linewidth':2,'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':'#aaa','chart.shadow.offsetx':0,'chart.shadow.offsety':0,'chart.shadow.blur':15,'chart.highlight.stroke':'rgba(0,0,0,0)','chart.highlight.fill':'rgba(255,0,0,0.7)','chart.tooltips':null,'chart.tooltips.highlight':true,'chart.tooltips.event':'onclick','chart.align':'center','chart.clearto':'rgba(0,0,0,0)'}
6
+ if(!this.canvas){alert('[DRAWING.MARKER1] No canvas support');return;}
7
+ this.$0={};this.coords=[];this.coordsText=[];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
+ prop[name]=value;return this;};this.get=this.Get=function(name)
15
+ {if(name.substr(0,6)!='chart.'){name='chart.'+name;}
16
+ while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
17
+ return prop[name.toLowerCase()];};this.draw=this.Draw=function()
18
+ {RG.FireCustomEvent(this,'onbeforedraw');var r=this.radius;if(prop['chart.align']=='left'){this.markerCenterx=this.centerx-r-r-3;this.markerCentery=this.centery-r-r-3;}else if(prop['chart.align']=='right'){this.markerCenterx=this.centerx+r+r+3;this.markerCentery=this.centery-r-r-3;}else{this.markerCenterx=this.centerx;this.markerCentery=this.centery-r-r-3;}
19
+ if(!this.colorsParsed){this.parseColors();this.colorsParsed=true;}
20
+ this.coordsText=[];pa2(co,['b','lw',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']);}
21
+ this.DrawMarker();pa2(co,['c','s',prop['chart.strokestyle'],'f',prop['chart.fillstyle']]);RG.NoShadow(this);co.fillStyle=prop['chart.text.color'];RG.Text2(this,{'font':prop['chart.text.font'],'size':prop['chart.text.size'],'x':this.coords[0][0]-1,'y':this.coords[0][1]-1,'text':this.text,'valign':'center','halign':'center','tag':'labels'});RG.InstallEventListeners(this);if(this.firstDraw){RG.fireCustomEvent(this,'onfirstdraw');this.firstDraw=false;this.firstDrawFunc();}
22
+ RG.FireCustomEvent(this,'ondraw');return this;};this.exec=function(func)
23
+ {func(this);return this;};this.getObjectByXY=function(e)
24
+ {if(this.getShape(e)){return this;}};this.getShape=function(e)
25
+ {var mouseXY=RG.getMouseXY(e);var mouseX=mouseXY[0];var mouseY=mouseXY[1];co.beginPath();this.DrawMarker();if(co.isPointInPath(mouseXY[0],mouseXY[1])){return{0:this,1:this.coords[0][0],2:this.coords[0][1],3:this.coords[0][2],4:0,'object':this,'x':this.coords[0][0],'y':this.coords[0][1],'radius':this.coords[0][2],'index':0,'tooltip':prop['chart.tooltips']?prop['chart.tooltips'][0]:null};}
26
+ return null;};this.highlight=this.Highlight=function(shape)
27
+ {if(prop['chart.tooltips.highlight']){if(typeof prop['chart.highlight.style']==='function'){(prop['chart.highlight.style'])(shape);}else{co.beginPath();co.strokeStyle=prop['chart.highlight.stroke'];co.fillStyle=prop['chart.highlight.fill'];this.drawMarker();co.closePath();co.stroke();co.fill();}}};this.drawMarker=this.DrawMarker=function()
28
+ {var r=this.radius;if(prop['chart.align']=='left'){var x=this.markerCenterx;var y=this.markerCentery;pa2(co,['a',x,y,r,RG.HALFPI,RG.TWOPI,false]);if(RG.ISOLD){pa2(co,['m',x+r+r,y+r+r,'qc',x+r,y+r,x+r+1,y,'m',x+r+r,y+r+r]);}else{pa2(co,['qc',x+r,y+r,x+r+r,y+r+r]);}
29
+ pa2(co,['qc',x+r,y+r,x,y+r+(RG.ISOLD?1:0)]);}else if(prop['chart.align']=='right'){var x=this.markerCenterx;var y=this.markerCentery;pa2(co,['a',x,y,r,RG.HALFPI,RG.PI,true]);if(RG.ISOLD){pa2(co,['m',x-r-r,y+r+r,'qc',x-r,y+r,x-r-1,y,'m',x-r-r,y+r+r]);}else{pa2(co,['qc',x-r,y+r,x-r-r,y+r+r]);}
30
+ pa2(co,['qc',x-r,y+r,x,y+r+(RG.ISOLD?1:0)]);}else{var x=this.markerCenterx;var y=this.markerCentery;pa2(co,['a',x,y,r,RG.HALFPI/2,RG.PI-(RG.HALFPI/2),true]);if(RG.ISOLD){pa2(co,['m',x,y+r+r-2,'qc',x,y+r+(r/4),x-(Math.cos(RG.HALFPI/2)*r),y+(Math.sin(RG.HALFPI/2)*r),'m',x,y+r+r-2]);}else{pa2(co,['qc',x,y+r+(r/4),x,y+r+r-2]);}
31
+ pa2(co,['qc',x,y+r+(r/4),x+(Math.cos(RG.HALFPI/2)*r),y+(Math.sin(RG.HALFPI/2)*r)]);}
32
+ this.coords[0]=[x,y,r];};this.parseColors=function()
33
+ {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']);}
34
+ 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()
35
+ {};this.parseSingleColorForGradient=function(color)
36
+ {if(!color||typeof(color)!='string'){return color;}
37
+ if(color.match(/^gradient\((.*)\)$/i)){var parts=RegExp.$1.split(':');var grad=co.createRadialGradient(this.markerCenterx,this.markerCentery,0,this.markerCenterx,this.markerCentery,this.radius);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]));}}
38
+ return grad?grad:color;};this.on=function(type,func)
39
+ {if(type.substr(0,2)!=='on'){type='on'+type;}
40
+ if(typeof this[type]!=='function'){this[type]=func;}else{RG.addCustomEventListener(this,type,func);}
41
+ return this;};this.firstDrawFunc=function()
42
+ {};RG.att(ca);RG.Register(this);if(parseConfObjectForOptions){RG.parseObjectStyleConfig(this,conf.options);}};