rgraph-rails 5.00 → 6.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/publish-geml.yaml +46 -0
- data/.gitignore +1 -0
- data/README.md +4 -5
- data/lib/rgraph-rails/version.rb +1 -1
- data/rgraph-rails.gemspec +4 -4
- data/vendor/assets/javascripts/RGraph.activity.js +1691 -0
- data/vendor/assets/javascripts/RGraph.bar.js +4253 -236
- data/vendor/assets/javascripts/RGraph.bipolar.js +3958 -162
- data/vendor/assets/javascripts/RGraph.common.annotate.js +414 -35
- data/vendor/assets/javascripts/RGraph.common.context.js +635 -30
- data/vendor/assets/javascripts/RGraph.common.core.js +10485 -419
- data/vendor/assets/javascripts/RGraph.common.csv.js +508 -27
- data/vendor/assets/javascripts/RGraph.common.dynamic.js +1693 -90
- data/vendor/assets/javascripts/RGraph.common.effects.js +1629 -89
- data/vendor/assets/javascripts/RGraph.common.key.js +1003 -53
- data/vendor/assets/javascripts/RGraph.common.moment.js +5670 -0
- data/vendor/assets/javascripts/RGraph.common.sheets.js +541 -31
- data/vendor/assets/javascripts/RGraph.common.sheets.php +351 -0
- data/vendor/assets/javascripts/RGraph.common.starburst.js +382 -0
- data/vendor/assets/javascripts/RGraph.common.table.js +386 -0
- data/vendor/assets/javascripts/RGraph.common.tooltips.js +1433 -32
- data/vendor/assets/javascripts/RGraph.drawing.background.js +660 -35
- data/vendor/assets/javascripts/RGraph.drawing.circle.js +618 -34
- data/vendor/assets/javascripts/RGraph.drawing.image.js +857 -52
- data/vendor/assets/javascripts/RGraph.drawing.line.js +712 -0
- data/vendor/assets/javascripts/RGraph.drawing.marker1.js +760 -38
- data/vendor/assets/javascripts/RGraph.drawing.marker2.js +740 -37
- data/vendor/assets/javascripts/RGraph.drawing.marker3.js +573 -36
- data/vendor/assets/javascripts/RGraph.drawing.poly.js +667 -36
- data/vendor/assets/javascripts/RGraph.drawing.rect.js +638 -34
- data/vendor/assets/javascripts/RGraph.drawing.text.js +672 -37
- data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +653 -52
- data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +714 -51
- data/vendor/assets/javascripts/RGraph.fuel.js +1149 -59
- data/vendor/assets/javascripts/RGraph.funnel.js +1277 -56
- data/vendor/assets/javascripts/RGraph.gantt.js +1646 -82
- data/vendor/assets/javascripts/RGraph.gauge.js +1773 -89
- data/vendor/assets/javascripts/RGraph.hbar.js +3869 -159
- data/vendor/assets/javascripts/RGraph.horseshoe.js +970 -0
- data/vendor/assets/javascripts/RGraph.hprogress.js +1829 -81
- data/vendor/assets/javascripts/RGraph.line.js +5293 -244
- data/vendor/assets/javascripts/RGraph.meter.js +1570 -77
- data/vendor/assets/javascripts/RGraph.modaldialog.js +300 -19
- data/vendor/assets/javascripts/RGraph.odo.js +1553 -68
- data/vendor/assets/javascripts/RGraph.pie.js +3273 -129
- data/vendor/assets/javascripts/RGraph.radar.js +2333 -108
- data/vendor/assets/javascripts/RGraph.rose.js +2685 -114
- data/vendor/assets/javascripts/RGraph.rscatter.js +1920 -80
- data/vendor/assets/javascripts/RGraph.scatter.js +4215 -171
- data/vendor/assets/javascripts/RGraph.segmented.js +1006 -0
- data/vendor/assets/javascripts/RGraph.semicircularprogress.js +1980 -59
- data/vendor/assets/javascripts/RGraph.svg.activity.js +1696 -0
- data/vendor/assets/javascripts/RGraph.svg.bar.js +2575 -77
- data/vendor/assets/javascripts/RGraph.svg.bipolar.js +3533 -106
- data/vendor/assets/javascripts/RGraph.svg.common.ajax.js +240 -21
- data/vendor/assets/javascripts/RGraph.svg.common.core.js +7105 -299
- data/vendor/assets/javascripts/RGraph.svg.common.csv.js +408 -28
- data/vendor/assets/javascripts/RGraph.svg.common.fx.js +1291 -68
- data/vendor/assets/javascripts/RGraph.svg.common.key.js +451 -20
- data/vendor/assets/javascripts/RGraph.svg.common.sheets.js +543 -31
- data/vendor/assets/javascripts/RGraph.svg.common.table.js +391 -0
- data/vendor/assets/javascripts/RGraph.svg.common.tooltips.js +1072 -23
- data/vendor/assets/javascripts/RGraph.svg.funnel.js +1151 -32
- data/vendor/assets/javascripts/RGraph.svg.gauge.js +1429 -34
- data/vendor/assets/javascripts/RGraph.svg.hbar.js +2692 -65
- data/vendor/assets/javascripts/RGraph.svg.horseshoe.js +969 -0
- data/vendor/assets/javascripts/RGraph.svg.line.js +2855 -86
- data/vendor/assets/javascripts/RGraph.svg.pie.js +1630 -58
- data/vendor/assets/javascripts/RGraph.svg.radar.js +1772 -58
- data/vendor/assets/javascripts/RGraph.svg.rose.js +2419 -83
- data/vendor/assets/javascripts/RGraph.svg.scatter.js +2280 -65
- data/vendor/assets/javascripts/RGraph.svg.segmented.js +930 -0
- data/vendor/assets/javascripts/RGraph.svg.semicircularprogress.js +1612 -29
- data/vendor/assets/javascripts/RGraph.svg.waterfall.js +1525 -50
- data/vendor/assets/javascripts/RGraph.thermometer.js +1411 -64
- data/vendor/assets/javascripts/RGraph.vprogress.js +1915 -81
- data/vendor/assets/javascripts/RGraph.waterfall.js +1896 -89
- data/vendor/assets/javascripts/financial-data.js +1067 -0
- metadata +37 -16
- data/.travis.yml +0 -11
- data/vendor/assets/javascripts/RGraph.common.deprecated.js +0 -35
- data/vendor/assets/javascripts/RGraph.common.resizing.js +0 -38
- data/vendor/assets/javascripts/RGraph.common.zoom.js +0 -15
- data/vendor/assets/javascripts/RGraph.cornergauge.js +0 -71
@@ -0,0 +1,712 @@
|
|
1
|
+
'version:2023-09-16 (6.14)';
|
2
|
+
//
|
3
|
+
// o--------------------------------------------------------------------------------o
|
4
|
+
// | This file is part of the RGraph package - you can learn more at: |
|
5
|
+
// | |
|
6
|
+
// | https://www.rgraph.net |
|
7
|
+
// | |
|
8
|
+
// | RGraph is licensed under the Open Source MIT license. That means that it's |
|
9
|
+
// | totally free to use and there are no restrictions on what you can do with it! |
|
10
|
+
// o--------------------------------------------------------------------------------o
|
11
|
+
|
12
|
+
|
13
|
+
//
|
14
|
+
// Having this here means that the RGraph libraries can be
|
15
|
+
// included in any order, instead of you having to include
|
16
|
+
// the common core library first.
|
17
|
+
//
|
18
|
+
|
19
|
+
// Define the RGraph global variable
|
20
|
+
RGraph = window.RGraph || {isrgraph:true,isRGraph: true,rgraph:true};
|
21
|
+
RGraph.Drawing = RGraph.Drawing || {};
|
22
|
+
|
23
|
+
//
|
24
|
+
// The constructor. This function sets up the object.
|
25
|
+
//
|
26
|
+
RGraph.Drawing.Line = function (conf)
|
27
|
+
{
|
28
|
+
var id = conf.id;
|
29
|
+
var coords = conf.coords;
|
30
|
+
|
31
|
+
this.id = id;
|
32
|
+
this.canvas = document.getElementById(this.id);
|
33
|
+
this.context = this.canvas.getContext('2d');
|
34
|
+
this.colorsParsed = false;
|
35
|
+
this.canvas.__object__ = this;
|
36
|
+
this.coords = coords;
|
37
|
+
this.coordsText = [];
|
38
|
+
this.original_colors = [];
|
39
|
+
this.firstDraw = true; // After the first draw this will be false
|
40
|
+
|
41
|
+
//
|
42
|
+
// This defines the type of this shape
|
43
|
+
//
|
44
|
+
this.type = 'drawing.line';
|
45
|
+
|
46
|
+
|
47
|
+
//
|
48
|
+
// This facilitates easy object identification, and should
|
49
|
+
// always be true
|
50
|
+
//
|
51
|
+
this.isRGraph = true;
|
52
|
+
this.isrgraph = true;
|
53
|
+
this.rgraph = true;
|
54
|
+
|
55
|
+
|
56
|
+
//
|
57
|
+
// This adds a uid to the object that you can use for
|
58
|
+
// identification purposes
|
59
|
+
//
|
60
|
+
this.uid = RGraph.createUID();
|
61
|
+
|
62
|
+
|
63
|
+
//
|
64
|
+
// This adds a UID to the canvas for identification purposes
|
65
|
+
//
|
66
|
+
this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.createUID();
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
//
|
72
|
+
// Some example background properties
|
73
|
+
//
|
74
|
+
this.properties =
|
75
|
+
{
|
76
|
+
linewidth: 1,
|
77
|
+
linecap: 'round',
|
78
|
+
linejoin: 'round',
|
79
|
+
|
80
|
+
colorsStroke: 'black',
|
81
|
+
|
82
|
+
tooltips: null,
|
83
|
+
tooltipsOverride: null,
|
84
|
+
tooltipsEffect: 'slide',
|
85
|
+
tooltipsCssClass: 'RGraph_tooltip',
|
86
|
+
tooltipsCss: {},
|
87
|
+
tooltipsEvent: 'onclick',
|
88
|
+
tooltipsHighlight: true,
|
89
|
+
tooltipsFormattedPoint: '.',
|
90
|
+
tooltipsFormattedThousand: ',',
|
91
|
+
tooltipsFormattedDecimals: 0,
|
92
|
+
tooltipsFormattedUnitsPre: '',
|
93
|
+
tooltipsFormattedUnitsPost: '',
|
94
|
+
tooltipsFormattedListType: 'ul',
|
95
|
+
tooltipsFormattedListItems: null,
|
96
|
+
tooltipsPointer: true,
|
97
|
+
tooltipsPointerOffsetx: 0,
|
98
|
+
tooltipsPointerOffsety: 0,
|
99
|
+
tooltipsPositionStatic: true,
|
100
|
+
|
101
|
+
highlightStyle: null,
|
102
|
+
highlightStroke: 'rgba(255,255,255,0.7)',
|
103
|
+
|
104
|
+
shadow: false,
|
105
|
+
shadowColor: 'rgba(0,0,0,0.2)',
|
106
|
+
shadowOffsetx: 3,
|
107
|
+
shadowOffsety: 3,
|
108
|
+
shadowBlur: 5,
|
109
|
+
|
110
|
+
|
111
|
+
text: null,
|
112
|
+
|
113
|
+
clearto: 'rgba(0,0,0,0)'
|
114
|
+
}
|
115
|
+
|
116
|
+
//
|
117
|
+
// A simple check that the browser has canvas support
|
118
|
+
//
|
119
|
+
if (!this.canvas) {
|
120
|
+
alert('[DRAWING.LINE] No canvas support');
|
121
|
+
return;
|
122
|
+
}
|
123
|
+
|
124
|
+
//
|
125
|
+
// Create the dollar object so that functions can be added to them
|
126
|
+
//
|
127
|
+
this.$0 = {};
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
// Easy access to properties and the path function
|
133
|
+
var properties = this.properties;
|
134
|
+
this.path = RGraph.pathObjectFunction;
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
//
|
139
|
+
// "Decorate" the object with the generic effects if the effects library has been included
|
140
|
+
//
|
141
|
+
if (RGraph.Effects && typeof RGraph.Effects.decorate === 'function') {
|
142
|
+
RGraph.Effects.decorate(this);
|
143
|
+
}
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
//
|
153
|
+
// A setter method for setting properties.
|
154
|
+
//
|
155
|
+
// @param name string The name of the property to set OR it can be a map
|
156
|
+
// of name/value settings like what you set in the constructor
|
157
|
+
//
|
158
|
+
this.set = function (name)
|
159
|
+
{
|
160
|
+
var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
|
161
|
+
|
162
|
+
// the number of arguments is only one and it's an
|
163
|
+
// object - parse it for configuration data and return.
|
164
|
+
if (arguments.length === 1 && typeof arguments[0] === 'object') {
|
165
|
+
for (i in arguments[0]) {
|
166
|
+
if (typeof i === 'string') {
|
167
|
+
this.set(i, arguments[0][i]);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
return this;
|
172
|
+
}
|
173
|
+
|
174
|
+
properties[name] = value;
|
175
|
+
|
176
|
+
return this;
|
177
|
+
};
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
//
|
187
|
+
// A getter method for retrieving graph properties. It can be used like this: obj.get('colorsStroke');
|
188
|
+
//
|
189
|
+
// @param name string The name of the property to get
|
190
|
+
//
|
191
|
+
this.get = function (name)
|
192
|
+
{
|
193
|
+
return properties[name];
|
194
|
+
};
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
//
|
204
|
+
// Draws the shape
|
205
|
+
//
|
206
|
+
this.draw = function ()
|
207
|
+
{
|
208
|
+
//
|
209
|
+
// Fire the onbeforedraw event
|
210
|
+
//
|
211
|
+
RGraph.fireCustomEvent(this, 'onbeforedraw');
|
212
|
+
|
213
|
+
|
214
|
+
// Translate half a pixel for antialiasing purposes - but
|
215
|
+
// only if it hasn't been done already
|
216
|
+
//
|
217
|
+
// MUST be the first thing done!
|
218
|
+
//
|
219
|
+
if (!this.canvas.__rgraph_aa_translated__) {
|
220
|
+
this.context.translate(0.5,0.5);
|
221
|
+
|
222
|
+
this.canvas.__rgraph_aa_translated__ = true;
|
223
|
+
}
|
224
|
+
|
225
|
+
//
|
226
|
+
// Parse the colors. This allows for simple gradient
|
227
|
+
// syntax
|
228
|
+
//
|
229
|
+
if (!this.colorsParsed) {
|
230
|
+
|
231
|
+
this.parseColors();
|
232
|
+
|
233
|
+
// Don't want to do this again
|
234
|
+
this.colorsParsed = true;
|
235
|
+
}
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
//
|
242
|
+
// Stop this growing uncontrollably
|
243
|
+
//
|
244
|
+
this.coordsText = [];
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
//
|
251
|
+
// DRAW THE LINE HERE
|
252
|
+
//
|
253
|
+
if (properties.shadow) {
|
254
|
+
RGraph.setShadow({
|
255
|
+
object: this,
|
256
|
+
prefix: 'shadow'
|
257
|
+
});
|
258
|
+
}
|
259
|
+
|
260
|
+
this.context.strokeStyle = properties.colorsStroke;
|
261
|
+
|
262
|
+
this.drawLine();
|
263
|
+
|
264
|
+
this.context.lineWidth = properties.linewidth;
|
265
|
+
RGraph.noShadow(this);
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
//
|
271
|
+
// Add custom text thats specified
|
272
|
+
//
|
273
|
+
RGraph.addCustomText(this);
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
//
|
282
|
+
// This installs the event listeners
|
283
|
+
//
|
284
|
+
RGraph.installEventListeners(this);
|
285
|
+
|
286
|
+
|
287
|
+
//
|
288
|
+
// Fire the onfirstdraw event
|
289
|
+
//
|
290
|
+
if (this.firstDraw) {
|
291
|
+
this.firstDraw = false;
|
292
|
+
RGraph.fireCustomEvent(this, 'onfirstdraw');
|
293
|
+
this.firstDrawFunc();
|
294
|
+
}
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
//
|
300
|
+
// Fire the draw event
|
301
|
+
//
|
302
|
+
RGraph.fireCustomEvent(this, 'ondraw');
|
303
|
+
|
304
|
+
return this;
|
305
|
+
};
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
//
|
315
|
+
// Used in chaining. Runs a function there and then - not waiting for
|
316
|
+
// the events to fire (eg the onbeforedraw event)
|
317
|
+
//
|
318
|
+
// @param function func The function to execute
|
319
|
+
//
|
320
|
+
this.exec = function (func)
|
321
|
+
{
|
322
|
+
func(this);
|
323
|
+
|
324
|
+
return this;
|
325
|
+
};
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
//
|
331
|
+
// The getObjectByXY() worker method
|
332
|
+
//
|
333
|
+
this.getObjectByXY = function (e)
|
334
|
+
{
|
335
|
+
if (this.getShape(e)) {
|
336
|
+
return this;
|
337
|
+
}
|
338
|
+
};
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
//
|
348
|
+
// Draws the path for the line - does not stroke or fill it
|
349
|
+
//
|
350
|
+
this.pathLine = function (coords, initial = 'm')
|
351
|
+
{
|
352
|
+
this.path(
|
353
|
+
'% % %',
|
354
|
+
initial,
|
355
|
+
coords[0][0],
|
356
|
+
coords[0][1]
|
357
|
+
);
|
358
|
+
|
359
|
+
// Draw lines to subsequent coords
|
360
|
+
for (var i=1,len=coords.length; i<len; ++i) {
|
361
|
+
this.context.lineTo(coords[i][0],coords[i][1]);
|
362
|
+
}
|
363
|
+
};
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
//
|
373
|
+
// Draw the Poly but doesn't stroke or fill - that's left to other functions
|
374
|
+
//
|
375
|
+
this.drawLine = function (opt)
|
376
|
+
{
|
377
|
+
// lineWidth given
|
378
|
+
if (opt && RGraph.isNumber(opt.linewidth)) {
|
379
|
+
var linewidth = opt.linewidth;
|
380
|
+
} else {
|
381
|
+
var linewidth = properties.linewidth;
|
382
|
+
}
|
383
|
+
|
384
|
+
var coords = this.coords;
|
385
|
+
|
386
|
+
this.path('b');
|
387
|
+
this.pathLine(coords);
|
388
|
+
|
389
|
+
// Stroke the line
|
390
|
+
this.path(
|
391
|
+
'lw % lj % lc % s %',
|
392
|
+
linewidth,
|
393
|
+
properties.linejoin,
|
394
|
+
properties.linecap,
|
395
|
+
this.context.strokeStyle
|
396
|
+
);
|
397
|
+
};
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
|
402
|
+
//
|
403
|
+
// Not used by the class during creating the graph, but
|
404
|
+
// is used by event handlers to get the coordinates (if
|
405
|
+
// any) of the line
|
406
|
+
//
|
407
|
+
// @param object e The event object
|
408
|
+
//
|
409
|
+
this.getShape = function (e)
|
410
|
+
{
|
411
|
+
var coords = this.coords,
|
412
|
+
mouseXY = RGraph.getMouseXY(e),
|
413
|
+
mouseX = mouseXY[0],
|
414
|
+
mouseY = mouseXY[1];
|
415
|
+
|
416
|
+
// Should redraw the line but not stroke or fill it and
|
417
|
+
// then use isPointInPath() to test it DON'T USE PATH
|
418
|
+
// OBJECT HERE
|
419
|
+
|
420
|
+
// Need to save these so that they can be reset
|
421
|
+
var old_strokestyle = this.context.strokeStyle;
|
422
|
+
|
423
|
+
this.context.beginPath();
|
424
|
+
this.context.strokeStyle = 'transparent';
|
425
|
+
this.drawLine({
|
426
|
+
linewidth: properties.linewidth + 5
|
427
|
+
});
|
428
|
+
|
429
|
+
// Reset the colors
|
430
|
+
this.context.strokeStyle = old_strokestyle;
|
431
|
+
|
432
|
+
|
433
|
+
if (this.context.isPointInStroke(mouseX, mouseY)) {
|
434
|
+
|
435
|
+
if (RGraph.parseTooltipText && properties.tooltips) {
|
436
|
+
var tooltip = RGraph.parseTooltipText(properties.tooltips, 0);
|
437
|
+
}
|
438
|
+
|
439
|
+
return {
|
440
|
+
object: this,
|
441
|
+
coords: this.coords,
|
442
|
+
dataset: 0,
|
443
|
+
index: 0,
|
444
|
+
sequentialIndex: 0,
|
445
|
+
tooltip: typeof tooltip === 'string' ? tooltip : null
|
446
|
+
};
|
447
|
+
}
|
448
|
+
|
449
|
+
return null;
|
450
|
+
};
|
451
|
+
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
//
|
460
|
+
// Each object type has its own Highlight() function which
|
461
|
+
// highlights the appropriate shape
|
462
|
+
//
|
463
|
+
// @param object shape The shape to highlight
|
464
|
+
//
|
465
|
+
this.highlight = function (shape)
|
466
|
+
{
|
467
|
+
// Add the new highlight
|
468
|
+
if (properties.tooltipsHighlight) {
|
469
|
+
if (typeof properties.highlightStyle === 'function') {
|
470
|
+
(properties.highlightStyle)(shape);
|
471
|
+
} else {
|
472
|
+
|
473
|
+
this.context.beginPath();
|
474
|
+
this.pathLine(this.coords);
|
475
|
+
this.path(
|
476
|
+
's %',
|
477
|
+
properties.highlightStroke
|
478
|
+
);
|
479
|
+
}
|
480
|
+
}
|
481
|
+
};
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
//
|
487
|
+
// This allows for easy specification of gradients
|
488
|
+
//
|
489
|
+
this.parseColors = function ()
|
490
|
+
{
|
491
|
+
|
492
|
+
// Save the original colors so that they can be restored when the canvas is reset
|
493
|
+
if (this.original_colors.length === 0) {
|
494
|
+
this.original_colors.colorsStroke = RGraph.arrayClone(properties.colorsStroke);
|
495
|
+
this.original_colors.highlightStroke = RGraph.arrayClone(properties.highlightStroke);
|
496
|
+
}
|
497
|
+
|
498
|
+
|
499
|
+
//
|
500
|
+
// Parse various properties for colors
|
501
|
+
//
|
502
|
+
properties.colorsStroke = this.parseSingleColorForGradient(properties.colorsStroke);
|
503
|
+
properties.highlightStroke = this.parseSingleColorForGradient(properties.highlightStroke);
|
504
|
+
};
|
505
|
+
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
//
|
514
|
+
// Use this function to reset the object to the post-constructor state. Eg reset colors if
|
515
|
+
// need be etc
|
516
|
+
//
|
517
|
+
this.reset = function ()
|
518
|
+
{
|
519
|
+
};
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
|
528
|
+
//
|
529
|
+
// This parses a single color value
|
530
|
+
//
|
531
|
+
this.parseSingleColorForGradient = function (color)
|
532
|
+
{
|
533
|
+
if (!color) {
|
534
|
+
return color;
|
535
|
+
}
|
536
|
+
|
537
|
+
if (typeof color === 'string' && color.match(/^gradient\((.*)\)$/i)) {
|
538
|
+
|
539
|
+
// Allow for JSON gradients
|
540
|
+
if (color.match(/^gradient\(({.*})\)$/i)) {
|
541
|
+
return RGraph.parseJSONGradient({object: this, def: RegExp.$1});
|
542
|
+
}
|
543
|
+
|
544
|
+
// Create the gradient
|
545
|
+
var parts = RegExp.$1.split(':'),
|
546
|
+
grad = this.context.createLinearGradient(0,0,this.canvas.width,0),
|
547
|
+
diff = 1 / (parts.length - 1);
|
548
|
+
|
549
|
+
grad.addColorStop(0, RGraph.trim(parts[0]));
|
550
|
+
|
551
|
+
for (var j=1,len=parts.length; j<len; ++j) {
|
552
|
+
grad.addColorStop(j * diff, RGraph.trim(parts[j]));
|
553
|
+
}
|
554
|
+
}
|
555
|
+
|
556
|
+
return grad ? grad : color;
|
557
|
+
};
|
558
|
+
|
559
|
+
|
560
|
+
|
561
|
+
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
|
566
|
+
//
|
567
|
+
// Using a function to add events makes it easier to facilitate method chaining
|
568
|
+
//
|
569
|
+
// @param string type The type of even to add
|
570
|
+
// @param function func
|
571
|
+
//
|
572
|
+
this.on = function (type, func)
|
573
|
+
{
|
574
|
+
if (type.substr(0,2) !== 'on') {
|
575
|
+
type = 'on' + type;
|
576
|
+
}
|
577
|
+
|
578
|
+
if (typeof this[type] !== 'function') {
|
579
|
+
this[type] = func;
|
580
|
+
} else {
|
581
|
+
RGraph.addCustomEventListener(this, type, func);
|
582
|
+
}
|
583
|
+
|
584
|
+
return this;
|
585
|
+
};
|
586
|
+
|
587
|
+
|
588
|
+
|
589
|
+
|
590
|
+
|
591
|
+
|
592
|
+
|
593
|
+
|
594
|
+
//
|
595
|
+
// This function runs once only
|
596
|
+
// (put at the end of the file (before any effects))
|
597
|
+
//
|
598
|
+
this.firstDrawFunc = function ()
|
599
|
+
{
|
600
|
+
};
|
601
|
+
|
602
|
+
|
603
|
+
|
604
|
+
|
605
|
+
|
606
|
+
|
607
|
+
|
608
|
+
|
609
|
+
//
|
610
|
+
// A worker function that handles Bar chart specific tooltip substitutions
|
611
|
+
//
|
612
|
+
this.tooltipSubstitutions = function (opt)
|
613
|
+
{
|
614
|
+
return {
|
615
|
+
index: 0,
|
616
|
+
dataset: 0,
|
617
|
+
sequentialIndex: 0,
|
618
|
+
value: null
|
619
|
+
};
|
620
|
+
};
|
621
|
+
|
622
|
+
|
623
|
+
|
624
|
+
|
625
|
+
|
626
|
+
|
627
|
+
|
628
|
+
|
629
|
+
//
|
630
|
+
// This allows for static tooltip positioning
|
631
|
+
//
|
632
|
+
this.positionTooltipStatic = function (args)
|
633
|
+
{
|
634
|
+
var obj = args.object,
|
635
|
+
e = args.event,
|
636
|
+
tooltip = args.tooltip,
|
637
|
+
index = args.index,
|
638
|
+
canvasXY = RGraph.getCanvasXY(obj.canvas);
|
639
|
+
/*
|
640
|
+
// Calculate the minimum X coordinate
|
641
|
+
var p1 = coords[0];
|
642
|
+
var p2 = coords[1];
|
643
|
+
|
644
|
+
var hypLength = RGraph.getHypLength({
|
645
|
+
x1: p1[0],
|
646
|
+
y1: p1[1],
|
647
|
+
x2: p2[0],
|
648
|
+
y2: p2[1]
|
649
|
+
});
|
650
|
+
|
651
|
+
var angle = RGraph.getAngleByXY({
|
652
|
+
cx: p1[0],
|
653
|
+
cy: p1[1],
|
654
|
+
x: p2[0],
|
655
|
+
y: p2[1]
|
656
|
+
});
|
657
|
+
|
658
|
+
// cx,cy,angle,radius
|
659
|
+
var point = RGraph.getRadiusEndPoint({
|
660
|
+
cx: p1[0],
|
661
|
+
cy: p1[1],
|
662
|
+
radius: hypLength / 2,
|
663
|
+
angle: angle
|
664
|
+
});
|
665
|
+
|
666
|
+
var x = point[0];
|
667
|
+
var y = point[1];
|
668
|
+
*/
|
669
|
+
|
670
|
+
var x = this.coords[0][0];
|
671
|
+
var y = this.coords[0][1];
|
672
|
+
|
673
|
+
// Position the tooltip in the X direction
|
674
|
+
args.tooltip.style.left = (
|
675
|
+
canvasXY[0] // The X coordinate of the canvas
|
676
|
+
- (tooltip.offsetWidth / 2) // Subtract half of the tooltip width
|
677
|
+
+ obj.properties.tooltipsOffsetx // Add any user defined offset
|
678
|
+
+ x
|
679
|
+
) + 'px';
|
680
|
+
|
681
|
+
args.tooltip.style.top = (
|
682
|
+
canvasXY[1] // The Y coordinate of the canvas
|
683
|
+
- tooltip.offsetHeight // The height of the tooltip
|
684
|
+
+ obj.properties.tooltipsOffsety // Add any user defined offset
|
685
|
+
+ y
|
686
|
+
- properties.linewidth
|
687
|
+
- 5
|
688
|
+
) + 'px';
|
689
|
+
};
|
690
|
+
|
691
|
+
|
692
|
+
|
693
|
+
|
694
|
+
|
695
|
+
|
696
|
+
|
697
|
+
|
698
|
+
//
|
699
|
+
// Objects are now always registered so that the chart
|
700
|
+
// is redrawn if need be.
|
701
|
+
//
|
702
|
+
RGraph.register(this);
|
703
|
+
|
704
|
+
|
705
|
+
|
706
|
+
|
707
|
+
//
|
708
|
+
// This is the 'end' of the constructor so if the first argument
|
709
|
+
// contains configuration data - handle that.
|
710
|
+
//
|
711
|
+
RGraph.parseObjectStyleConfig(this, conf.options);
|
712
|
+
};
|