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
@@ -1,35 +1,639 @@
|
|
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
|
+
// Having this here means that the RGraph libraries can be included in any order, instead of you having
|
14
|
+
// to include the common core library first.
|
15
|
+
//
|
1
16
|
|
2
|
-
RGraph
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
17
|
+
// Define the RGraph global variable
|
18
|
+
RGraph = window.RGraph || {isrgraph:true,isRGraph: true,rgraph:true};
|
19
|
+
RGraph.Drawing = RGraph.Drawing || {};
|
20
|
+
|
21
|
+
//
|
22
|
+
// The constructor. This function sets up the object.
|
23
|
+
//
|
24
|
+
RGraph.Drawing.Rect = function (conf)
|
25
|
+
{
|
26
|
+
var id = conf.id,
|
27
|
+
x = conf.x,
|
28
|
+
y = conf.y,
|
29
|
+
width = conf.width,
|
30
|
+
height = conf.height;
|
31
|
+
|
32
|
+
|
33
|
+
// id, x, y, w, h
|
34
|
+
this.id = id;
|
35
|
+
this.canvas = document.getElementById(this.id);
|
36
|
+
this.context = this.canvas.getContext('2d');
|
37
|
+
this.colorsParsed = false;
|
38
|
+
this.canvas.__object__ = this;
|
39
|
+
this.original_colors = [];
|
40
|
+
this.coordsText = [];
|
41
|
+
this.firstDraw = true; // After the first draw this will be false
|
42
|
+
|
43
|
+
//
|
44
|
+
// This defines the type of this shape
|
45
|
+
//
|
46
|
+
this.type = 'drawing.rect';
|
47
|
+
|
48
|
+
|
49
|
+
//
|
50
|
+
// This facilitates easy object identification, and should always be true
|
51
|
+
//
|
52
|
+
this.isRGraph = true;
|
53
|
+
this.isrgraph = true;
|
54
|
+
this.rgraph = true;
|
55
|
+
|
56
|
+
|
57
|
+
//
|
58
|
+
// This adds a uid to the object that you can use for 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
|
+
colorsStroke: 'rgba(0,0,0,0)',
|
77
|
+
colorsFill: 'red',
|
78
|
+
|
79
|
+
shadow: false,
|
80
|
+
shadowColor: 'gray',
|
81
|
+
shadowOffsetx: 3,
|
82
|
+
shadowOffsety: 3,
|
83
|
+
shadowBlur: 5,
|
84
|
+
|
85
|
+
|
86
|
+
text: null,
|
87
|
+
|
88
|
+
highlightStroke: 'black',
|
89
|
+
highlightFill: 'rgba(255,255,255,0.7)',
|
90
|
+
|
91
|
+
tooltips: null,
|
92
|
+
tooltipsEffect: 'slide',
|
93
|
+
tooltipsCssClass: 'RGraph_tooltip',
|
94
|
+
tooltipsCss: null,
|
95
|
+
tooltipsEvent: 'onclick',
|
96
|
+
tooltipsHighlight: true,
|
97
|
+
tooltipsCoordsPage: false,
|
98
|
+
tooltipsValign: 'top',
|
99
|
+
tooltipsFormattedPoint: '.',
|
100
|
+
tooltipsFormattedThousand: ',',
|
101
|
+
tooltipsFormattedDecimals: 0,
|
102
|
+
tooltipsFormattedUnitsPre: '',
|
103
|
+
tooltipsFormattedUnitsPost: '',
|
104
|
+
tooltipsFormattedListType: 'ul',
|
105
|
+
tooltipsFormattedListItems: null,
|
106
|
+
tooltipsPointer: true,
|
107
|
+
tooltipsPointerOffsetx: 0,
|
108
|
+
tooltipsPointerOffsety: 0,
|
109
|
+
tooltipsPositionStatic: true,
|
110
|
+
|
111
|
+
clearto: 'rgba(0,0,0,0)'
|
112
|
+
}
|
113
|
+
|
114
|
+
//
|
115
|
+
// A simple check that the browser has canvas support
|
116
|
+
//
|
117
|
+
if (!this.canvas) {
|
118
|
+
alert('[DRAWING.RECT] No canvas support');
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
|
122
|
+
//
|
123
|
+
// This can be used to store the coordinates of shapes on the graph
|
124
|
+
//
|
125
|
+
|
126
|
+
this.coords = [[
|
127
|
+
Math.round(x),
|
128
|
+
Math.round(y),
|
129
|
+
width,
|
130
|
+
height
|
131
|
+
]];
|
132
|
+
|
133
|
+
//
|
134
|
+
// Create the dollar object so that functions can be added to them
|
135
|
+
//
|
136
|
+
this.$0 = {};
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
// Easy access to properties and the path function
|
141
|
+
var properties = this.properties;
|
142
|
+
this.path = RGraph.pathObjectFunction;
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
//
|
147
|
+
// "Decorate" the object with the generic effects if the effects library has been included
|
148
|
+
//
|
149
|
+
if (RGraph.Effects && typeof RGraph.Effects.decorate === 'function') {
|
150
|
+
RGraph.Effects.decorate(this);
|
151
|
+
}
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
//
|
161
|
+
// A setter method for setting graph properties. It can be used like this: obj.set('colorsStroke', '#666');
|
162
|
+
//
|
163
|
+
// @param name string The name of the property to set
|
164
|
+
// @param value mixed The value of the property
|
165
|
+
//
|
166
|
+
this.set = function (name)
|
167
|
+
{
|
168
|
+
var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
|
169
|
+
|
170
|
+
// the number of arguments is only one and it's an
|
171
|
+
// object - parse it for configuration data and return.
|
172
|
+
if (arguments.length === 1 && typeof arguments[0] === 'object') {
|
173
|
+
for (i in arguments[0]) {
|
174
|
+
if (typeof i === 'string') {
|
175
|
+
this.set(i, arguments[0][i]);
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
return this;
|
180
|
+
}
|
181
|
+
|
182
|
+
properties[name] = value;
|
183
|
+
|
184
|
+
return this;
|
185
|
+
};
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
//
|
195
|
+
// A getter method for retrieving graph properties. It can be used like this: obj.get('colorsStroke');
|
196
|
+
//
|
197
|
+
// @param name string The name of the property to get
|
198
|
+
//
|
199
|
+
this.get = function (name)
|
200
|
+
{
|
201
|
+
return properties[name];
|
202
|
+
};
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
//
|
212
|
+
// Draws the rectangle
|
213
|
+
//
|
214
|
+
this.draw = function ()
|
215
|
+
{
|
216
|
+
//
|
217
|
+
// Fire the onbeforedraw event
|
218
|
+
//
|
219
|
+
RGraph.fireCustomEvent(this, 'onbeforedraw');
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
// Translate half a pixel for antialiasing purposes - but only if it hasn't been
|
224
|
+
// done already
|
225
|
+
//
|
226
|
+
// MUST be the first thing done!
|
227
|
+
//
|
228
|
+
if (!this.canvas.__rgraph_aa_translated__) {
|
229
|
+
this.context.translate(0.5,0.5);
|
230
|
+
|
231
|
+
this.canvas.__rgraph_aa_translated__ = true;
|
232
|
+
}
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
//
|
237
|
+
// Stop this growing uncntrollably
|
238
|
+
//
|
239
|
+
this.coordsText = [];
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
//
|
245
|
+
// Parse the colors. This allows for simple gradient syntax
|
246
|
+
//
|
247
|
+
if (!this.colorsParsed) {
|
248
|
+
|
249
|
+
this.parseColors();
|
250
|
+
|
251
|
+
// Don't want to do this again
|
252
|
+
this.colorsParsed = true;
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
//
|
257
|
+
// Draw the rect here
|
258
|
+
//
|
259
|
+
this.path('b');
|
260
|
+
|
261
|
+
if (properties.shadow) {
|
262
|
+
this.path(
|
263
|
+
'sc % sx % sy % sb %',
|
264
|
+
properties.shadowColor,
|
265
|
+
properties.shadowOffsetx,
|
266
|
+
properties.shadowOffsety,
|
267
|
+
properties.shadowBlur
|
268
|
+
);
|
269
|
+
}
|
270
|
+
|
271
|
+
this.path(
|
272
|
+
'r % % % % f %',
|
273
|
+
this.coords[0][0], this.coords[0][1], this.coords[0][2], this.coords[0][3],
|
274
|
+
properties.colorsFill
|
275
|
+
);
|
276
|
+
|
277
|
+
|
278
|
+
// No shadow to stroke the rectangle
|
279
|
+
RGraph.noShadow(this);
|
280
|
+
|
281
|
+
this.path('s %', properties.colorsStroke);
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
//
|
287
|
+
// Add custom text thats specified
|
288
|
+
//
|
289
|
+
RGraph.addCustomText(this);
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
//
|
297
|
+
// This installs the event listeners
|
298
|
+
//
|
299
|
+
RGraph.installEventListeners(this);
|
300
|
+
|
301
|
+
|
302
|
+
//
|
303
|
+
// Fire the onfirstdraw event
|
304
|
+
//
|
305
|
+
if (this.firstDraw) {
|
306
|
+
this.firstDraw = false;
|
307
|
+
RGraph.fireCustomEvent(this, 'onfirstdraw');
|
308
|
+
this.firstDrawFunc();
|
309
|
+
}
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
//
|
315
|
+
// Fire the draw event
|
316
|
+
//
|
317
|
+
RGraph.fireCustomEvent(this, 'ondraw');
|
318
|
+
|
319
|
+
return this;
|
320
|
+
};
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
//
|
330
|
+
// Used in chaining. Runs a function there and then - not waiting for
|
331
|
+
// the events to fire (eg the onbeforedraw event)
|
332
|
+
//
|
333
|
+
// @param function func The function to execute
|
334
|
+
//
|
335
|
+
this.exec = function (func)
|
336
|
+
{
|
337
|
+
func(this);
|
338
|
+
|
339
|
+
return this;
|
340
|
+
};
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
//
|
350
|
+
// The getObjectByXY() worker method
|
351
|
+
//
|
352
|
+
this.getObjectByXY = function (e)
|
353
|
+
{
|
354
|
+
if (this.getShape(e)) {
|
355
|
+
return this;
|
356
|
+
}
|
357
|
+
};
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
//
|
367
|
+
// Not used by the class during creating the graph, but is used by event handlers
|
368
|
+
// to get the coordinates (if any) of the selected bar
|
369
|
+
//
|
370
|
+
// @param object e The event object
|
371
|
+
// @param object OPTIONAL You can pass in the bar object instead of the
|
372
|
+
// function using "this"
|
373
|
+
//
|
374
|
+
this.getShape = function (e)
|
375
|
+
{
|
376
|
+
var mouseXY = RGraph.getMouseXY(e),
|
377
|
+
mouseX = mouseXY[0],
|
378
|
+
mouseY = mouseXY[1];
|
379
|
+
|
380
|
+
for (var i=0,len=this.coords.length; i<len; i++) {
|
381
|
+
|
382
|
+
var coords = this.coords[i];
|
383
|
+
|
384
|
+
var left = coords[0],
|
385
|
+
top = coords[1],
|
386
|
+
width = coords[2],
|
387
|
+
height = coords[3];
|
388
|
+
|
389
|
+
if (mouseX >= left && mouseX <= (left + width) && mouseY >= top && mouseY <= (top + height)) {
|
390
|
+
|
391
|
+
if (RGraph.parseTooltipText && properties.tooltips) {
|
392
|
+
var tooltip = RGraph.parseTooltipText(properties.tooltips, 0);
|
393
|
+
}
|
394
|
+
|
395
|
+
return {
|
396
|
+
object: this,
|
397
|
+
x: left,
|
398
|
+
y: top,
|
399
|
+
width: width,
|
400
|
+
height: height,
|
401
|
+
dataset: 0,
|
402
|
+
index: 0,
|
403
|
+
sequentialIndex: 0,
|
404
|
+
tooltip: typeof tooltip === 'string' ? tooltip : null
|
405
|
+
};
|
406
|
+
}
|
407
|
+
}
|
408
|
+
|
409
|
+
return null;
|
410
|
+
};
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
//
|
420
|
+
// Each object type has its own Highlight() function which highlights the appropriate shape
|
421
|
+
//
|
422
|
+
// @param object shape The shape to highlight
|
423
|
+
//
|
424
|
+
this.highlight = function (shape)
|
425
|
+
{
|
426
|
+
if (typeof properties.highlightStyle === 'function') {
|
427
|
+
(properties.highlightStyle)(shape);
|
428
|
+
} else {
|
429
|
+
RGraph.Highlight.rect(this, shape);
|
430
|
+
}
|
431
|
+
};
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
//
|
441
|
+
// This allows for easy specification of gradients
|
442
|
+
//
|
443
|
+
this.parseColors = function ()
|
444
|
+
{
|
445
|
+
// Save the original colors so that they can be restored when the canvas is reset
|
446
|
+
if (this.original_colors.length === 0) {
|
447
|
+
this.original_colors.colorsFill = RGraph.arrayClone(properties.colorsFill);
|
448
|
+
this.original_colors.colorsStroke = RGraph.arrayClone(properties.colorsStroke);
|
449
|
+
this.original_colors.highlightStroke = RGraph.arrayClone(properties.highlightStroke);
|
450
|
+
this.original_colors.highlightFill = RGraph.arrayClone(properties.highlightFill);
|
451
|
+
}
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
//
|
457
|
+
// Parse various properties for colors
|
458
|
+
//
|
459
|
+
properties.colorsFill = this.parseSingleColorForGradient(properties.colorsFill);
|
460
|
+
properties.colorsStroke = this.parseSingleColorForGradient(properties.colorsStroke);
|
461
|
+
properties.highlightStroke = this.parseSingleColorForGradient(properties.highlightStroke);
|
462
|
+
properties.highlightFill = this.parseSingleColorForGradient(properties.highlightFill);
|
463
|
+
};
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
//
|
473
|
+
// Use this function to reset the object to the post-constructor state. Eg reset colors if
|
474
|
+
// need be etc
|
475
|
+
//
|
476
|
+
this.reset = function ()
|
477
|
+
{
|
478
|
+
};
|
479
|
+
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
//
|
488
|
+
// This parses a single color value
|
489
|
+
//
|
490
|
+
this.parseSingleColorForGradient = function (color)
|
491
|
+
{
|
492
|
+
if (!color) {
|
493
|
+
return color;
|
494
|
+
}
|
495
|
+
|
496
|
+
if (typeof color === 'string' && color.match(/^gradient\((.*)\)$/i)) {
|
497
|
+
|
498
|
+
// Allow for JSON gradients
|
499
|
+
if (color.match(/^gradient\(({.*})\)$/i)) {
|
500
|
+
return RGraph.parseJSONGradient({object: this, def: RegExp.$1});
|
501
|
+
}
|
502
|
+
|
503
|
+
var parts = RegExp.$1.split(':'),
|
504
|
+
grad = this.context.createLinearGradient(0,0,this.canvas.width,0),
|
505
|
+
diff = 1 / (parts.length - 1);
|
506
|
+
|
507
|
+
grad.addColorStop(0, RGraph.trim(parts[0]));
|
508
|
+
|
509
|
+
for (var j=1,len=parts.length; j<len; ++j) {
|
510
|
+
grad.addColorStop(j * diff, RGraph.trim(parts[j]));
|
511
|
+
}
|
512
|
+
}
|
513
|
+
|
514
|
+
return grad ? grad : color;
|
515
|
+
};
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
|
524
|
+
//
|
525
|
+
// Using a function to add events makes it easier to facilitate method chaining
|
526
|
+
//
|
527
|
+
// @param string type The type of even to add
|
528
|
+
// @param function func
|
529
|
+
//
|
530
|
+
this.on = function (type, func)
|
531
|
+
{
|
532
|
+
if (type.substr(0,2) !== 'on') {
|
533
|
+
type = 'on' + type;
|
534
|
+
}
|
535
|
+
|
536
|
+
if (typeof this[type] !== 'function') {
|
537
|
+
this[type] = func;
|
538
|
+
} else {
|
539
|
+
RGraph.addCustomEventListener(this, type, func);
|
540
|
+
}
|
541
|
+
|
542
|
+
return this;
|
543
|
+
};
|
544
|
+
|
545
|
+
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
//
|
553
|
+
// This function runs once only
|
554
|
+
// (put at the end of the file (before any effects))
|
555
|
+
//
|
556
|
+
this.firstDrawFunc = function ()
|
557
|
+
{
|
558
|
+
};
|
559
|
+
|
560
|
+
|
561
|
+
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
//
|
568
|
+
// A worker function that handles Bar chart specific tooltip substitutions
|
569
|
+
//
|
570
|
+
this.tooltipSubstitutions = function (opt)
|
571
|
+
{
|
572
|
+
return {
|
573
|
+
index: 0,
|
574
|
+
dataset: 0,
|
575
|
+
sequentialIndex: 0,
|
576
|
+
value: null
|
577
|
+
};
|
578
|
+
};
|
579
|
+
|
580
|
+
|
581
|
+
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
|
586
|
+
|
587
|
+
//
|
588
|
+
// This allows for static tooltip positioning
|
589
|
+
//
|
590
|
+
this.positionTooltipStatic = function (args)
|
591
|
+
{
|
592
|
+
var obj = args.object,
|
593
|
+
e = args.event,
|
594
|
+
tooltip = args.tooltip,
|
595
|
+
index = args.index,
|
596
|
+
canvasXY = RGraph.getCanvasXY(obj.canvas);
|
597
|
+
|
598
|
+
// Position the tooltip in the X direction
|
599
|
+
args.tooltip.style.left = (
|
600
|
+
canvasXY[0] // The X coordinate of the canvas
|
601
|
+
+ this.coords[0][0] + (this.coords[0][2] / 2) // The X coordinate of the rect
|
602
|
+
- (tooltip.offsetWidth / 2) // Subtract half of the tooltip width
|
603
|
+
+ obj.properties.tooltipsOffsetx // Add any user defined offset
|
604
|
+
) + 'px';
|
605
|
+
|
606
|
+
args.tooltip.style.top = (
|
607
|
+
canvasXY[1] // The Y coordinate of the canvas
|
608
|
+
- tooltip.offsetHeight // The height of the tooltip
|
609
|
+
+ obj.properties.tooltipsOffsety // Add any user defined offset
|
610
|
+
+ this.coords[0][1] // The X coordinate of the rect
|
611
|
+
- 10 // An arbitrary amount
|
612
|
+
) + 'px';
|
613
|
+
};
|
614
|
+
|
615
|
+
|
616
|
+
|
617
|
+
|
618
|
+
|
619
|
+
|
620
|
+
|
621
|
+
|
622
|
+
//
|
623
|
+
// Objects are now always registered so that the chart is redrawn if need be.
|
624
|
+
//
|
625
|
+
RGraph.register(this);
|
626
|
+
|
627
|
+
|
628
|
+
|
629
|
+
|
630
|
+
|
631
|
+
|
632
|
+
|
633
|
+
|
634
|
+
//
|
635
|
+
// This is the 'end' of the constructor so if the first argument
|
636
|
+
// contains configuration data - handle that.
|
637
|
+
//
|
638
|
+
RGraph.parseObjectStyleConfig(this, conf.options);
|
639
|
+
};
|