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,82 +1,1830 @@
|
|
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
|
1
11
|
|
2
|
-
RGraph=window.RGraph||{isRGraph:true};
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
this.
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
this.
|
31
|
-
this.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
12
|
+
RGraph = window.RGraph || {isrgraph:true,isRGraph:true,rgraph:true};
|
13
|
+
|
14
|
+
// The progress bar constructor
|
15
|
+
RGraph.HProgress = function (conf)
|
16
|
+
{
|
17
|
+
var id = conf.id,
|
18
|
+
canvas = document.getElementById(id),
|
19
|
+
min = conf.min,
|
20
|
+
max = conf.max,
|
21
|
+
value = conf.value;
|
22
|
+
this.id = id;
|
23
|
+
this.canvas = canvas;
|
24
|
+
this.context = this.canvas.getContext('2d');
|
25
|
+
this.canvas.__object__ = this;
|
26
|
+
this.min = RGraph.stringsToNumbers(min);
|
27
|
+
this.max = RGraph.stringsToNumbers(max);
|
28
|
+
this.value = RGraph.stringsToNumbers(value);
|
29
|
+
this.type = 'hprogress';
|
30
|
+
this.coords = [];
|
31
|
+
this.isRGraph = true;
|
32
|
+
this.isrgraph = true;
|
33
|
+
this.rgraph = true;
|
34
|
+
this.currentValue = null;
|
35
|
+
this.uid = RGraph.createUID();
|
36
|
+
this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.createUID();
|
37
|
+
this.colorsParsed = false;
|
38
|
+
this.coordsText = [];
|
39
|
+
this.original_colors = [];
|
40
|
+
this.firstDraw = true; // After the first draw this will be false
|
41
|
+
this.stopAnimationRequested = false;// Used to control the animations
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
this.properties =
|
51
|
+
{
|
52
|
+
colors: ['#0c0','red','green','yellow','pink','cyan','black','white','gray'],
|
53
|
+
colorsStrokeInner: '#999',
|
54
|
+
colorsStrokeOuter: '#999',
|
55
|
+
|
56
|
+
tickmarksColor: '#999',
|
57
|
+
tickmarksInnerCount: 0,
|
58
|
+
tickmarksOuterCount: 0,
|
59
|
+
|
60
|
+
backgroundColor: 'Gradient(#ccc:#eee:#efefef)',
|
61
|
+
|
62
|
+
marginLeft: 35,
|
63
|
+
marginRight: 35,
|
64
|
+
marginTop: 35,
|
65
|
+
marginBottom: 35,
|
66
|
+
|
67
|
+
shadow: false,
|
68
|
+
shadowColor: 'rgba(0,0,0,0.5)',
|
69
|
+
shadowBlur: 3,
|
70
|
+
shadowOffsetx: 3,
|
71
|
+
shadowOffsety: 3,
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
title: '',
|
76
|
+
titleX: null,
|
77
|
+
titleY: null,
|
78
|
+
titleHalign: null,
|
79
|
+
titleValign: null,
|
80
|
+
titleFont: null,
|
81
|
+
titleSize: null,
|
82
|
+
titleColor: null,
|
83
|
+
titleBold: null,
|
84
|
+
titleItalic: null,
|
85
|
+
titleOffsetx: 0,
|
86
|
+
titleOffsety: 0,
|
87
|
+
titleSubtitle: '',
|
88
|
+
titleSubtitleSize: null,
|
89
|
+
titleSubtitleColor: '#aaa',
|
90
|
+
titleSubtitleFont: null,
|
91
|
+
titleSubtitleBold: null,
|
92
|
+
titleSubtitleItalic: null,
|
93
|
+
titleSubtitleOffsetx: 0,
|
94
|
+
titleSubtitleOffsety: 0,
|
95
|
+
|
96
|
+
textSize: 12,
|
97
|
+
textColor: 'black',
|
98
|
+
textFont: 'Arial, Verdana, sans-serif',
|
99
|
+
textBold: false,
|
100
|
+
textItalic: false,
|
101
|
+
textAccessible: false,
|
102
|
+
textAccessibleOverflow: 'visible',
|
103
|
+
textAccessiblePointerevents: false,
|
104
|
+
text: null,
|
105
|
+
|
106
|
+
contextmenu: null,
|
107
|
+
|
108
|
+
scaleUnitsPre: '',
|
109
|
+
scaleUnitsPost: '',
|
110
|
+
scaleDecimals: 0,
|
111
|
+
scalePoint: '.',
|
112
|
+
scaleThousand: ',',
|
113
|
+
|
114
|
+
adjustable: false,
|
115
|
+
|
116
|
+
tooltips: null,
|
117
|
+
tooltipsEffect: 'slide',
|
118
|
+
tooltipsCssClass: 'RGraph_tooltip',
|
119
|
+
tooltipsCss: null,
|
120
|
+
tooltipsHighlight: true,
|
121
|
+
tooltipsEvent: 'onclick',
|
122
|
+
tooltipsFormattedThousand: ',',
|
123
|
+
tooltipsFormattedPoint: '.',
|
124
|
+
tooltipsFormattedDecimals: 0,
|
125
|
+
tooltipsFormattedUnitsPre: '',
|
126
|
+
tooltipsFormattedUnitsPost: '',
|
127
|
+
tooltipsFormattedKeyColors: null,
|
128
|
+
tooltipsFormattedKeyColorsShape: 'square',
|
129
|
+
tooltipsFormattedKeyLabels: [],
|
130
|
+
tooltipsFormattedListType: 'ul',
|
131
|
+
tooltipsFormattedListItems: null,
|
132
|
+
tooltipsFormattedTableHeaders: null,
|
133
|
+
tooltipsFormattedTableData: null,
|
134
|
+
tooltipsPointer: true,
|
135
|
+
tooltipsPointerOffsetx: 0,
|
136
|
+
tooltipsPointerOffsety: 0,
|
137
|
+
tooltipsPositionStatic: true,
|
138
|
+
tooltipsHotspotIgnore: null,
|
139
|
+
|
140
|
+
highlightLinewidth: 1,
|
141
|
+
highlightStroke: 'rgba(0,0,0,0)',
|
142
|
+
highlightFill: 'rgba(255,255,255,0.7)',
|
143
|
+
|
144
|
+
annotatable: false,
|
145
|
+
annotateColor: 'black',
|
146
|
+
|
147
|
+
arrows: false,
|
148
|
+
|
149
|
+
marginInner: 0,
|
150
|
+
|
151
|
+
labelsPosition: 'bottom',
|
152
|
+
labelsSpecific: null,
|
153
|
+
labelsSpecificFormattedDecimals: 0,
|
154
|
+
labelsSpecificFormattedPoint: '.',
|
155
|
+
labelsSpecificFormattedThousand: ',',
|
156
|
+
labelsSpecificFormattedUnitsPre: '',
|
157
|
+
labelsSpecificFormattedUnitsPost: '',
|
158
|
+
labelsCount: 10,
|
159
|
+
labelsOffsetx: 0,
|
160
|
+
labelsOffsety: 0,
|
161
|
+
labelsFont: null,
|
162
|
+
labelsSize: null,
|
163
|
+
labelsColor: null,
|
164
|
+
labelsBold: null,
|
165
|
+
labelsItalic: null,
|
166
|
+
|
167
|
+
labelsInner: false,
|
168
|
+
labelsInnerFont: null,
|
169
|
+
labelsInnerSize: null,
|
170
|
+
labelsInnerColor: null,
|
171
|
+
labelsInnerBold: null,
|
172
|
+
labelsInnerItalic: null,
|
173
|
+
labelsInnerOffsetx: 0,
|
174
|
+
labelsInnerOffsety: 0,
|
175
|
+
labelsInnerDecimals: 0,
|
176
|
+
labelsInnerBackgroundFill: 'rgba(255,255,255,0.7)',
|
177
|
+
labelsInnerBorder: true,
|
178
|
+
labelsInnerBorderLinewidth: 1,
|
179
|
+
labelsInnerBorderColor: '#ccc',
|
180
|
+
labelsInnerScalePoint: null,
|
181
|
+
labelsInnerScaleThousand: null,
|
182
|
+
labelsInnerUnitsPre: '',
|
183
|
+
labelsInnerUnitsPost: '',
|
184
|
+
labelsInnerSpecific: null,
|
185
|
+
|
186
|
+
key: null,
|
187
|
+
keyBackground: 'white',
|
188
|
+
keyPosition: 'margin',
|
189
|
+
keyHalign: 'right',
|
190
|
+
keyShadow: false,
|
191
|
+
keyShadowColor: '#666',
|
192
|
+
keyShadowBlur: 3,
|
193
|
+
keyShadowOffsetx: 2,
|
194
|
+
keyShadowOffsety: 2,
|
195
|
+
keyPositionMarginBoxed: false,
|
196
|
+
keyPositionMarginHSpace: 0,
|
197
|
+
keyPositionX: null,
|
198
|
+
keyPositionY: null,
|
199
|
+
keyColorShape: 'square',
|
200
|
+
keyRounded: true,
|
201
|
+
keyLinewidth: 1,
|
202
|
+
keyColors: null,
|
203
|
+
keyColorShape: 'square',
|
204
|
+
keyInteractive: false,
|
205
|
+
keyInteractiveHighlightChartStroke: 'black',
|
206
|
+
keyInteractiveHighlightChartFill: 'rgba(255,255,255,0.7)',
|
207
|
+
keyInteractiveHighlightLabel: 'rgba(255,0,0,0.2)',
|
208
|
+
keyLabelsColor: null,
|
209
|
+
keyLabelsFont: null,
|
210
|
+
keyLabelsSize: null,
|
211
|
+
keyLabelsBold: null,
|
212
|
+
keyLabelsItalic: null,
|
213
|
+
keyLabelsOffsetx: 0,
|
214
|
+
keyLabelsOffsety: 0,
|
215
|
+
keyFormattedDecimals: 0,
|
216
|
+
keyFormattedPoint: '.',
|
217
|
+
keyFormattedThousand: ',',
|
218
|
+
keyFormattedUnitsPre: '',
|
219
|
+
keyFormattedUnitsPost: '',
|
220
|
+
keyFormattedValueSpecific: null,
|
221
|
+
keyFormattedItemsCount: null,
|
222
|
+
|
223
|
+
borderInner: true,
|
224
|
+
|
225
|
+
beveled: false,
|
226
|
+
|
227
|
+
clearto: 'rgba(0,0,0,0)'
|
228
|
+
}
|
229
|
+
|
230
|
+
|
231
|
+
// Check for support
|
232
|
+
if (!this.canvas) {
|
233
|
+
alert('[HPROGRESS] No canvas support');
|
234
|
+
return;
|
235
|
+
}
|
236
|
+
|
237
|
+
|
238
|
+
//
|
239
|
+
// Create the dollar objects so that functions can be added to them
|
240
|
+
//
|
241
|
+
var linear_data = RGraph.arrayLinearize(value);
|
242
|
+
for (var i=0; i<linear_data.length; ++i) {
|
243
|
+
this['$' + i] = {};
|
244
|
+
}
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
// Short variable names
|
249
|
+
var properties = this.properties;
|
250
|
+
this.path = RGraph.pathObjectFunction;
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
//
|
255
|
+
// "Decorate" the object with the generic effects if the effects library has been included
|
256
|
+
//
|
257
|
+
if (RGraph.Effects && typeof RGraph.Effects.decorate === 'function') {
|
258
|
+
RGraph.Effects.decorate(this);
|
259
|
+
}
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
// Add the responsive method. This method resides in the common file.
|
264
|
+
this.responsive = RGraph.responsive;
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
//
|
270
|
+
// A generic setter
|
271
|
+
//
|
272
|
+
// @param string name The name of the property to set
|
273
|
+
// @param string value The value of the poperty
|
274
|
+
//
|
275
|
+
this.set = function (name)
|
276
|
+
{
|
277
|
+
var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
|
278
|
+
|
279
|
+
if (name === 'bevelled') {
|
280
|
+
name = 'beveled';
|
281
|
+
}
|
282
|
+
|
283
|
+
// the number of arguments is only one and it's an
|
284
|
+
// object - parse it for configuration data and return.
|
285
|
+
if (arguments.length === 1 && typeof arguments[0] === 'object') {
|
286
|
+
for (i in arguments[0]) {
|
287
|
+
if (typeof i === 'string') {
|
288
|
+
this.set(i, arguments[0][i]);
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
return this;
|
293
|
+
}
|
294
|
+
|
295
|
+
properties[name] = value;
|
296
|
+
|
297
|
+
return this;
|
298
|
+
};
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
//
|
308
|
+
// A generic getter
|
309
|
+
//
|
310
|
+
// @param string name The name of the property to get
|
311
|
+
//
|
312
|
+
this.get = function (name)
|
313
|
+
{
|
314
|
+
return properties[name];
|
315
|
+
};
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
//
|
325
|
+
// Draws the progress bar
|
326
|
+
//
|
327
|
+
this.draw = function ()
|
328
|
+
{
|
329
|
+
//
|
330
|
+
// Fire the onbeforedraw event
|
331
|
+
//
|
332
|
+
RGraph.fireCustomEvent(this, 'onbeforedraw');
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
// Translate half a pixel for antialiasing purposes - but only if it hasn't been
|
337
|
+
// done already
|
338
|
+
//
|
339
|
+
// MUST be the first thing done!
|
340
|
+
//
|
341
|
+
if (!this.canvas.__rgraph_aa_translated__) {
|
342
|
+
this.context.translate(0.5,0.5);
|
343
|
+
|
344
|
+
this.canvas.__rgraph_aa_translated__ = true;
|
345
|
+
}
|
346
|
+
|
347
|
+
//
|
348
|
+
// Parse the colors. This allows for simple gradient syntax
|
349
|
+
//
|
350
|
+
if (!this.colorsParsed) {
|
351
|
+
|
352
|
+
this.parseColors();
|
353
|
+
|
354
|
+
|
355
|
+
// Don't want to do this again
|
356
|
+
this.colorsParsed = true;
|
357
|
+
}
|
358
|
+
|
359
|
+
|
360
|
+
//
|
361
|
+
// Set the current value
|
362
|
+
//
|
363
|
+
this.currentValue = this.value;
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
//
|
368
|
+
// Make the margins easy ro access
|
369
|
+
//
|
370
|
+
this.marginLeft = properties.marginLeft;
|
371
|
+
this.marginRight = properties.marginRight;
|
372
|
+
this.marginTop = properties.marginTop;
|
373
|
+
this.marginBottom = properties.marginBottom;
|
374
|
+
|
375
|
+
// Figure out the width and height
|
376
|
+
this.width = this.canvas.width - this.marginLeft - this.marginRight;
|
377
|
+
this.height = this.canvas.height - this.marginTop - this.marginBottom;
|
378
|
+
this.coords = [];
|
379
|
+
this.coordsText = [];
|
380
|
+
|
381
|
+
this.drawbar();
|
382
|
+
this.drawTickMarks();
|
383
|
+
this.drawLabels();
|
384
|
+
this.drawTitle();
|
385
|
+
|
386
|
+
|
387
|
+
//
|
388
|
+
// Draw the bevel effect if requested
|
389
|
+
//
|
390
|
+
if (properties.beveled) {
|
391
|
+
this.drawBevel();
|
392
|
+
}
|
393
|
+
|
394
|
+
|
395
|
+
//
|
396
|
+
// Setup the context menu if required
|
397
|
+
//
|
398
|
+
if (properties.contextmenu) {
|
399
|
+
RGraph.showContext(this);
|
400
|
+
}
|
401
|
+
|
402
|
+
|
403
|
+
// Draw the key if necessary
|
404
|
+
if (properties.key && properties.key.length) {
|
405
|
+
RGraph.drawKey(
|
406
|
+
this,
|
407
|
+
properties.key,
|
408
|
+
properties.colors
|
409
|
+
);
|
410
|
+
}
|
411
|
+
|
412
|
+
//
|
413
|
+
// Reset the strokestyle to black
|
414
|
+
//
|
415
|
+
this.context.strokeStyle = 'black';
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
//
|
421
|
+
// Add custom text thats specified
|
422
|
+
//
|
423
|
+
RGraph.addCustomText(this);
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
//
|
434
|
+
// This installs the event listeners
|
435
|
+
//
|
436
|
+
RGraph.installEventListeners(this);
|
437
|
+
|
438
|
+
//
|
439
|
+
// Fire the onfirstdraw event
|
440
|
+
//
|
441
|
+
if (this.firstDraw) {
|
442
|
+
this.firstDraw = false;
|
443
|
+
RGraph.fireCustomEvent(this, 'onfirstdraw');
|
444
|
+
this.firstDrawFunc();
|
445
|
+
}
|
446
|
+
|
447
|
+
|
448
|
+
//
|
449
|
+
// Fire the RGraph draw event
|
450
|
+
//
|
451
|
+
RGraph.fireCustomEvent(this, 'ondraw');
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
//
|
461
|
+
// Install any inline responsive configuration. This
|
462
|
+
// should be last in the draw function - even after
|
463
|
+
// the draw events.
|
464
|
+
//
|
465
|
+
RGraph.installInlineResponsive(this);
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
return this;
|
482
|
+
};
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
//
|
492
|
+
// Used in chaining. Runs a function there and then - not waiting for
|
493
|
+
// the events to fire (eg the onbeforedraw event)
|
494
|
+
//
|
495
|
+
// @param function func The function to execute
|
496
|
+
//
|
497
|
+
this.exec = function (func)
|
498
|
+
{
|
499
|
+
func(this);
|
500
|
+
|
501
|
+
return this;
|
502
|
+
};
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
//
|
512
|
+
// Draws the bar
|
513
|
+
//
|
514
|
+
this.drawbar = function ()
|
515
|
+
{
|
516
|
+
//
|
517
|
+
// First get the scale
|
518
|
+
//
|
519
|
+
this.scale2 = RGraph.getScale({object: this, options: {
|
520
|
+
'scale.max': this.max,
|
521
|
+
'scale.min': this.min,
|
522
|
+
'scale.strict': true,
|
523
|
+
'scale.thousand': properties.scaleThousand,
|
524
|
+
'scale.point': properties.scalePoint,
|
525
|
+
'scale.decimals': properties.scaleDecimals,
|
526
|
+
'scale.labels.count': properties.labelsCount,
|
527
|
+
'scale.round': properties.scaleRound,
|
528
|
+
'scale.units.pre': properties.scaleUnitsPre,
|
529
|
+
'scale.units.post': properties.scaleUnitsPost
|
530
|
+
}});
|
531
|
+
|
532
|
+
// Set a shadow if requested
|
533
|
+
if (properties.shadow) {
|
534
|
+
RGraph.setShadow({
|
535
|
+
object: this,
|
536
|
+
prefix: 'shadow'
|
537
|
+
});
|
538
|
+
}
|
539
|
+
|
540
|
+
// Draw the outline
|
541
|
+
this.context.fillStyle = properties.backgroundColor;
|
542
|
+
this.context.strokeStyle = properties.colorsStrokeOuter;
|
543
|
+
|
544
|
+
this.context.strokeRect(this.marginLeft, this.marginTop, this.width, this.height);
|
545
|
+
this.context.fillRect(this.marginLeft, this.marginTop, this.width, this.height);
|
546
|
+
|
547
|
+
// Turn off any shadow
|
548
|
+
RGraph.noShadow(this);
|
549
|
+
|
550
|
+
this.context.fillStyle = properties.colors[0];
|
551
|
+
this.context.strokeStyle = properties.colorsStrokeOuter;
|
552
|
+
|
553
|
+
var margin = properties.marginInner;
|
554
|
+
|
555
|
+
// Draw the actual bar itself
|
556
|
+
var barWidth = Math.min(this.width, ((RGraph.arraySum(this.value) - this.min) / (this.max - this.min) ) * this.width);
|
557
|
+
|
558
|
+
if (properties.tickmarksInnerCount > 0) {
|
559
|
+
|
560
|
+
var spacing = (this.canvas.width - this.marginLeft - this.marginRight) / properties.tickmarksInnerCount;
|
561
|
+
|
562
|
+
this.context.lineWidth = 1;
|
563
|
+
this.context.strokeStyle = properties.colorsStrokeOuter;
|
564
|
+
|
565
|
+
this.context.beginPath();
|
566
|
+
for (var x = this.marginLeft; x<this.canvas.width - this.marginRight; x+=spacing) {
|
567
|
+
this.context.moveTo(Math.round(x), this.marginTop);
|
568
|
+
this.context.lineTo(Math.round(x), this.marginTop + 2);
|
569
|
+
|
570
|
+
this.context.moveTo(Math.round(x), this.canvas.height - this.marginBottom);
|
571
|
+
this.context.lineTo(Math.round(x), this.canvas.height - this.marginBottom - 2);
|
572
|
+
}
|
573
|
+
this.context.stroke();
|
574
|
+
}
|
575
|
+
|
576
|
+
|
577
|
+
//
|
578
|
+
// This bit draws the actual progress bar
|
579
|
+
//
|
580
|
+
if (typeof this.value === 'number') {
|
581
|
+
|
582
|
+
if (properties.borderInner) {
|
583
|
+
this.drawCurvedBar({
|
584
|
+
x: this.marginLeft,
|
585
|
+
y: this.marginTop + margin,
|
586
|
+
width: barWidth,
|
587
|
+
height: this.height - margin - margin,
|
588
|
+
stroke: properties.colorsStrokeInner
|
589
|
+
});
|
590
|
+
}
|
591
|
+
|
592
|
+
this.drawCurvedBar({
|
593
|
+
x: this.marginLeft,
|
594
|
+
y: this.marginTop + margin,
|
595
|
+
width: barWidth,
|
596
|
+
height: this.height - margin - margin,
|
597
|
+
fill: properties.colors[0]
|
598
|
+
});
|
599
|
+
|
600
|
+
// Store the coords
|
601
|
+
this.coords.push([
|
602
|
+
this.marginLeft,
|
603
|
+
this.marginTop + margin,
|
604
|
+
barWidth,
|
605
|
+
this.height - margin - margin
|
606
|
+
]);
|
607
|
+
|
608
|
+
} else if (typeof this.value === 'object') {
|
609
|
+
|
610
|
+
this.context.beginPath();
|
611
|
+
|
612
|
+
var startPoint = this.marginLeft;
|
613
|
+
|
614
|
+
for (var i=0,len=this.value.length; i<len; ++i) {
|
615
|
+
|
616
|
+
var segmentLength = (this.value[i] / RGraph.arraySum(this.value)) * barWidth;
|
617
|
+
|
618
|
+
if (properties.borderInner) {
|
619
|
+
this.drawCurvedBar({
|
620
|
+
x: startPoint,
|
621
|
+
y: this.marginTop + margin,
|
622
|
+
width: segmentLength,
|
623
|
+
height: this.height - margin - margin,
|
624
|
+
fill: properties.colors[i],
|
625
|
+
stroke: properties.colorsStrokeInner
|
626
|
+
});
|
627
|
+
}
|
628
|
+
|
629
|
+
this.drawCurvedBar({
|
630
|
+
x: startPoint,
|
631
|
+
y: this.marginTop + margin,
|
632
|
+
width: segmentLength,
|
633
|
+
height: this.height - margin - margin,
|
634
|
+
fill: properties.colors[i]
|
635
|
+
});
|
636
|
+
|
637
|
+
|
638
|
+
// Store the coords
|
639
|
+
this.coords.push([
|
640
|
+
startPoint,
|
641
|
+
this.marginTop + margin,
|
642
|
+
segmentLength,
|
643
|
+
this.height - margin - margin
|
644
|
+
]);
|
645
|
+
|
646
|
+
startPoint += segmentLength;
|
647
|
+
}
|
648
|
+
}
|
649
|
+
|
650
|
+
//
|
651
|
+
// Draw the arrows indicating the level if requested
|
652
|
+
//
|
653
|
+
if (properties.arrows) {
|
654
|
+
var x = this.marginLeft + barWidth;
|
655
|
+
var y = this.marginTop;
|
656
|
+
|
657
|
+
this.context.lineWidth = 1;
|
658
|
+
this.context.fillStyle = 'black';
|
659
|
+
this.context.strokeStyle = 'black';
|
660
|
+
|
661
|
+
this.context.beginPath();
|
662
|
+
this.context.moveTo(x, y - 3);
|
663
|
+
this.context.lineTo(x + 2, y - 7);
|
664
|
+
this.context.lineTo(x - 2, y - 7);
|
665
|
+
this.context.closePath();
|
666
|
+
|
667
|
+
this.context.stroke();
|
668
|
+
this.context.fill();
|
669
|
+
|
670
|
+
this.context.beginPath();
|
671
|
+
this.context.moveTo(x, y + this.height + 4);
|
672
|
+
this.context.lineTo(x + 2, y + this.height + 9);
|
673
|
+
this.context.lineTo(x - 2, y + this.height + 9);
|
674
|
+
this.context.closePath();
|
675
|
+
|
676
|
+
this.context.stroke();
|
677
|
+
this.context.fill()
|
678
|
+
}
|
679
|
+
|
680
|
+
|
681
|
+
|
682
|
+
|
683
|
+
|
684
|
+
|
685
|
+
|
686
|
+
|
687
|
+
|
688
|
+
|
689
|
+
//
|
690
|
+
// Draw the inner label
|
691
|
+
//
|
692
|
+
if (properties.labelsInner) {
|
693
|
+
|
694
|
+
// Format the number
|
695
|
+
if (typeof properties.labelsInnerSpecific === 'string') {
|
696
|
+
var text = String(properties.labelsInnerSpecific);
|
697
|
+
} else {
|
698
|
+
|
699
|
+
var value = typeof this.value === 'number' ? this.value : RGraph.arraySum(this.value);
|
700
|
+
var value = value.toFixed(typeof properties.labelsInnerDecimals === 'number' ? properties.labelsInnerDecimals : properties.scaleDecimals);
|
701
|
+
var text = RGraph.numberFormat({
|
702
|
+
object: this,
|
703
|
+
number: value,
|
704
|
+
unitspre: typeof properties.labelsInnerUnitsPre === 'string' ? properties.labelsInnerUnitsPre : properties.scaleUnitsPre,
|
705
|
+
unitspost: typeof properties.labelsInnerUnitsPost === 'string' ? properties.labelsInnerUnitsPost : properties.scaleUnitsPost,
|
706
|
+
point: typeof properties.labelsInnerPoint === 'string' ? properties.labelsInnerPoint : properties.scalePoint,
|
707
|
+
thousand: typeof properties.labelsInnerThousand === 'string' ? properties.labelsInnerThousand : properties.scaleThousand
|
708
|
+
});
|
709
|
+
}
|
710
|
+
|
711
|
+
var textConf = RGraph.getTextConf({
|
712
|
+
object: this,
|
713
|
+
prefix: 'labelsInner'
|
714
|
+
});
|
715
|
+
|
716
|
+
RGraph.text({
|
717
|
+
|
718
|
+
object: this,
|
719
|
+
|
720
|
+
font: textConf.font,
|
721
|
+
size: textConf.size,
|
722
|
+
color: textConf.color,
|
723
|
+
bold: textConf.bold,
|
724
|
+
italic: textConf.italic,
|
725
|
+
|
726
|
+
x: this.marginLeft + barWidth + 5 + properties.labelsInnerOffsetx,
|
727
|
+
y: this.marginTop + (this.height / 2) + properties.labelsInnerOffsety,
|
728
|
+
|
729
|
+
text: text,
|
730
|
+
valign: 'center',
|
731
|
+
halign: 'left',
|
732
|
+
bounding: typeof properties.labelsInnerBackgroundFill === 'string' ? true : false,
|
733
|
+
boundingFill: properties.labelsInnerBackgroundFill,
|
734
|
+
boundingStroke: properties.labelsInnerBorder ? properties.labelsInnerBorderColor : 'rgba(0,0,0,0)',
|
735
|
+
boundingLinewidth: properties.labelsInnerBorderLinewidth,
|
736
|
+
tag: 'label.inner'
|
737
|
+
});
|
738
|
+
}
|
739
|
+
|
740
|
+
// This is here to stop colors being changed by later fills
|
741
|
+
this.path('b');
|
742
|
+
};
|
743
|
+
|
744
|
+
|
745
|
+
|
746
|
+
|
747
|
+
|
748
|
+
|
749
|
+
|
750
|
+
|
751
|
+
//
|
752
|
+
// The function that draws the tick marks. Apt name...
|
753
|
+
//
|
754
|
+
this.drawTickMarks = function ()
|
755
|
+
{
|
756
|
+
this.context.strokeStyle = properties.tickmarksColor;
|
757
|
+
|
758
|
+
if (properties.tickmarksOuterCount > 0) {
|
759
|
+
|
760
|
+
this.context.beginPath();
|
761
|
+
|
762
|
+
// This is used by the label function below
|
763
|
+
this.tickInterval = this.width / properties.tickmarksOuterCount;
|
764
|
+
|
765
|
+
var start = 0;
|
766
|
+
|
767
|
+
if (properties.labelsPosition === 'top') {
|
768
|
+
for (var i=this.marginLeft + start; i<=(this.width + this.marginLeft + 0.1); i+=this.tickInterval) {
|
769
|
+
this.context.moveTo(Math.round(i), this.marginTop);
|
770
|
+
this.context.lineTo(Math.round(i), this.marginTop - 4);
|
771
|
+
}
|
772
|
+
|
773
|
+
} else {
|
774
|
+
|
775
|
+
for (var i=this.marginLeft + start; i<=(this.width + this.marginLeft + 0.1); i+=this.tickInterval) {
|
776
|
+
this.context.moveTo(Math.round(i), this.marginTop + this.height);
|
777
|
+
this.context.lineTo(Math.round(i), this.marginTop + this.height + 4);
|
778
|
+
}
|
779
|
+
}
|
780
|
+
|
781
|
+
this.context.stroke();
|
782
|
+
}
|
783
|
+
};
|
784
|
+
|
785
|
+
|
786
|
+
|
787
|
+
|
788
|
+
|
789
|
+
|
790
|
+
|
791
|
+
|
792
|
+
//
|
793
|
+
// The function that draws the labels
|
794
|
+
//
|
795
|
+
this.drawLabels = function ()
|
796
|
+
{
|
797
|
+
if (!RGraph.isNull(properties.labelsSpecific)) {
|
798
|
+
return this.drawSpecificLabels();
|
799
|
+
}
|
800
|
+
|
801
|
+
this.context.fillStyle = properties.textColor;
|
802
|
+
|
803
|
+
var xPoints = [],
|
804
|
+
yPoints = [],
|
805
|
+
bold = properties.textBold,
|
806
|
+
italic = properties.textItalic,
|
807
|
+
color = properties.textColor,
|
808
|
+
font = properties.textFont,
|
809
|
+
size = properties.textSize,
|
810
|
+
offsetx = properties.labelsOffsetx,
|
811
|
+
offsety = properties.labelsOffsety;
|
812
|
+
|
813
|
+
for (i=0,len=this.scale2.labels.length; i<len; i++) {
|
814
|
+
|
815
|
+
if (properties.labelsPosition == 'top') {
|
816
|
+
var x = this.width * (i/this.scale2.labels.length) + this.marginLeft + (this.width / this.scale2.labels.length);
|
817
|
+
var y = this.marginTop - 6;
|
818
|
+
var valign = 'bottom';
|
819
|
+
} else {
|
820
|
+
var x = this.width * (i/this.scale2.labels.length) + this.marginLeft + (this.width / this.scale2.labels.length);
|
821
|
+
var y = this.height + this.marginTop + 4;
|
822
|
+
var valign = 'top';
|
823
|
+
}
|
824
|
+
|
825
|
+
var textConf = RGraph.getTextConf({
|
826
|
+
object: this,
|
827
|
+
prefix: 'labels'
|
828
|
+
});
|
829
|
+
|
830
|
+
|
831
|
+
RGraph.text({
|
832
|
+
|
833
|
+
object: this,
|
834
|
+
|
835
|
+
font: textConf.font,
|
836
|
+
size: textConf.size,
|
837
|
+
color: textConf.color,
|
838
|
+
bold: textConf.bold,
|
839
|
+
italic: textConf.italic,
|
840
|
+
|
841
|
+
x: x + offsetx,
|
842
|
+
y: y + offsety,
|
843
|
+
text: this.scale2.labels[i],
|
844
|
+
valign: valign,
|
845
|
+
halign: 'center',
|
846
|
+
tag: 'scale'
|
847
|
+
});
|
848
|
+
}
|
849
|
+
|
850
|
+
var text = RGraph.numberFormat({
|
851
|
+
object: this,
|
852
|
+
number: Number(this.min).toFixed(properties.scaleDecimals),
|
853
|
+
unitspre: properties.scaleUnitsPre,
|
854
|
+
unitspost: properties.scaleUnitsPost
|
855
|
+
});
|
856
|
+
|
857
|
+
if (properties.labelsPosition == 'top') {
|
858
|
+
RGraph.text({
|
859
|
+
|
860
|
+
object: this,
|
861
|
+
|
862
|
+
font: textConf.font,
|
863
|
+
size: textConf.size,
|
864
|
+
color: textConf.color,
|
865
|
+
bold: textConf.bold,
|
866
|
+
italic: textConf.italic,
|
867
|
+
|
868
|
+
x: this.marginLeft + offsetx,
|
869
|
+
y: this.marginTop - 6 + offsety,
|
870
|
+
text: text,
|
871
|
+
valign: 'bottom',
|
872
|
+
halign: 'center',
|
873
|
+
tag: 'scale'
|
874
|
+
});
|
875
|
+
} else {
|
876
|
+
|
877
|
+
RGraph.text({
|
878
|
+
|
879
|
+
object: this,
|
880
|
+
|
881
|
+
font: textConf.font,
|
882
|
+
size: textConf.size,
|
883
|
+
color: textConf.color,
|
884
|
+
bold: textConf.bold,
|
885
|
+
italic: textConf.italic,
|
886
|
+
|
887
|
+
x: this.marginLeft + offsetx,
|
888
|
+
y: this.canvas.height - this.marginBottom + 5 + offsety,
|
889
|
+
text: text,
|
890
|
+
valign: 'top',
|
891
|
+
halign: 'center',
|
892
|
+
tag: 'scale'
|
893
|
+
});
|
894
|
+
}
|
895
|
+
};
|
896
|
+
|
897
|
+
|
898
|
+
|
899
|
+
|
900
|
+
|
901
|
+
|
902
|
+
|
903
|
+
|
904
|
+
//
|
905
|
+
// Returns the focused bar
|
906
|
+
//
|
907
|
+
// @param event e The event object
|
908
|
+
//
|
909
|
+
this.getShape = function (e)
|
910
|
+
{
|
911
|
+
var mouseXY = RGraph.getMouseXY(e),
|
912
|
+
mouseX = mouseXY[0],
|
913
|
+
mouseY = mouseXY[1];
|
914
|
+
|
915
|
+
for (var i=0,len=this.coords.length; i<len; i++) {
|
916
|
+
|
917
|
+
if (RGraph.tooltipsHotspotIgnore(this, i)) {
|
918
|
+
continue;
|
919
|
+
}
|
920
|
+
|
921
|
+
var x = this.coords[i][0],
|
922
|
+
y = this.coords[i][1],
|
923
|
+
w = this.coords[i][2],
|
924
|
+
h = this.coords[i][3],
|
925
|
+
idx = i;
|
926
|
+
|
927
|
+
this.context.beginPath();
|
928
|
+
this.drawCurvedBar({
|
929
|
+
x: x,
|
930
|
+
y: y,
|
931
|
+
height: h,
|
932
|
+
width: w
|
933
|
+
});
|
934
|
+
|
935
|
+
if (this.context.isPointInPath(mouseX, mouseY)) {
|
936
|
+
|
937
|
+
if (RGraph.parseTooltipText) {
|
938
|
+
var tooltip = RGraph.parseTooltipText(properties.tooltips, idx);
|
939
|
+
}
|
940
|
+
|
941
|
+
return {
|
942
|
+
object: this,
|
943
|
+
x: x,
|
944
|
+
y: y,
|
945
|
+
width: w,
|
946
|
+
height: h,
|
947
|
+
dataset: 0,
|
948
|
+
index: idx,
|
949
|
+
sequentialIndex: idx,
|
950
|
+
tooltip: typeof tooltip === 'string' ? tooltip : null
|
951
|
+
}
|
952
|
+
}
|
953
|
+
}
|
954
|
+
};
|
955
|
+
|
956
|
+
|
957
|
+
|
958
|
+
|
959
|
+
|
960
|
+
|
961
|
+
|
962
|
+
|
963
|
+
//
|
964
|
+
// This function returns the value that the mouse is positioned at, regardless of
|
965
|
+
// the actual indicated value.
|
966
|
+
//
|
967
|
+
// @param object e The event object
|
968
|
+
//
|
969
|
+
this.getValue = function (e)
|
970
|
+
{
|
971
|
+
var mouseXY = RGraph.getMouseXY(e);
|
972
|
+
|
973
|
+
var value = (mouseXY[0] - this.marginLeft) / this.width;
|
974
|
+
value *= this.max - this.min;
|
975
|
+
value += this.min;
|
976
|
+
|
977
|
+
if (mouseXY[0] < this.marginLeft) {
|
978
|
+
value = this.min;
|
979
|
+
}
|
980
|
+
if (mouseXY[0] > (this.canvas.width - this.marginRight) ) {
|
981
|
+
value = this.max
|
982
|
+
}
|
983
|
+
|
984
|
+
return value;
|
985
|
+
};
|
986
|
+
|
987
|
+
|
988
|
+
|
989
|
+
|
990
|
+
|
991
|
+
|
992
|
+
|
993
|
+
|
994
|
+
//
|
995
|
+
// Each object type has its own Highlight() function which
|
996
|
+
// highlights the appropriate shape.
|
997
|
+
//
|
998
|
+
// @param object shape The shape to highlight
|
999
|
+
//
|
1000
|
+
this.highlight = function (shape)
|
1001
|
+
{
|
1002
|
+
var last = shape.index === this.coords.length - 1;
|
1003
|
+
|
1004
|
+
if (!properties.tooltipsHighlight) {
|
1005
|
+
return;
|
1006
|
+
}
|
1007
|
+
|
1008
|
+
// Call a function to highlight the chart
|
1009
|
+
if (typeof properties.highlightStyle === 'function') {
|
1010
|
+
(properties.highlightStyle)(shape);
|
1011
|
+
|
1012
|
+
// Highlight all of the rects except the selected one - essentially an inverted highlight
|
1013
|
+
} else if (typeof properties.highlightStyle === 'string' && properties.highlightStyle === 'invert') {
|
1014
|
+
for (var i=0; i<this.coords.length; ++i) {
|
1015
|
+
if (i !== shape.sequentialIndex) {
|
1016
|
+
this.path(
|
1017
|
+
'b lw % r % % % % s % f %',
|
1018
|
+
properties.highlightLinewidth,
|
1019
|
+
this.coords[i][0] - 0.5,this.coords[i][1] - 0.5, this.coords[i][2] + 1, this.coords[i][3] + 1,
|
1020
|
+
properties.highlightStroke,
|
1021
|
+
properties.highlightFill
|
1022
|
+
);
|
1023
|
+
}
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
} else {
|
1027
|
+
|
1028
|
+
this.path('lw %', properties.highlightLinewidth);
|
1029
|
+
|
1030
|
+
this.drawCurvedBar({
|
1031
|
+
x: shape.x - 0.5,
|
1032
|
+
y: shape.y - 0.5,
|
1033
|
+
width: shape.width + 1,
|
1034
|
+
height: shape.height + 1,
|
1035
|
+
stroke: properties.highlightStroke,
|
1036
|
+
fill: properties.highlightFill
|
1037
|
+
});
|
1038
|
+
|
1039
|
+
// Reset the linewidth
|
1040
|
+
this.path('lw %', 1);
|
1041
|
+
}
|
1042
|
+
};
|
1043
|
+
|
1044
|
+
|
1045
|
+
|
1046
|
+
|
1047
|
+
|
1048
|
+
|
1049
|
+
|
1050
|
+
|
1051
|
+
//
|
1052
|
+
// The getObjectByXY() worker method. Don't call this call:
|
1053
|
+
//
|
1054
|
+
// RGraph.ObjectRegistry.getObjectByXY(e)
|
1055
|
+
//
|
1056
|
+
// @param object e The event object
|
1057
|
+
//
|
1058
|
+
this.getObjectByXY = function (e)
|
1059
|
+
{
|
1060
|
+
var mouseXY = RGraph.getMouseXY(e);
|
1061
|
+
|
1062
|
+
if (
|
1063
|
+
mouseXY[0] > this.marginLeft
|
1064
|
+
&& mouseXY[0] < (this.canvas.width - this.marginRight)
|
1065
|
+
&& mouseXY[1] > this.marginTop
|
1066
|
+
&& mouseXY[1] < (this.canvas.height - this.marginBottom)
|
1067
|
+
) {
|
1068
|
+
|
1069
|
+
return this;
|
1070
|
+
}
|
1071
|
+
};
|
1072
|
+
|
1073
|
+
|
1074
|
+
|
1075
|
+
|
1076
|
+
|
1077
|
+
|
1078
|
+
|
1079
|
+
|
1080
|
+
//
|
1081
|
+
// This method handles the adjusting calculation for when the mouse is moved
|
1082
|
+
//
|
1083
|
+
// @param object e The event object
|
1084
|
+
//
|
1085
|
+
this.adjusting_mousemove = function (e)
|
1086
|
+
{
|
1087
|
+
//
|
1088
|
+
// Handle adjusting for the HProgress
|
1089
|
+
//
|
1090
|
+
if (properties.adjustable && RGraph.Registry.get('adjusting') && RGraph.Registry.get('adjusting').uid == this.uid) {
|
1091
|
+
|
1092
|
+
var mouseXY = RGraph.getMouseXY(e);
|
1093
|
+
var value = this.getValue(e);
|
1094
|
+
|
1095
|
+
if (typeof value === 'number') {
|
1096
|
+
|
1097
|
+
this.value = Number(value.toFixed(properties.scaleDecimals));
|
1098
|
+
RGraph.redrawCanvas(this.canvas);
|
1099
|
+
|
1100
|
+
// Fire the onadjust event
|
1101
|
+
RGraph.fireCustomEvent(this, 'onadjust');
|
1102
|
+
}
|
1103
|
+
}
|
1104
|
+
};
|
1105
|
+
|
1106
|
+
|
1107
|
+
|
1108
|
+
|
1109
|
+
|
1110
|
+
|
1111
|
+
|
1112
|
+
|
1113
|
+
//
|
1114
|
+
// Draws labelsSpecific
|
1115
|
+
//
|
1116
|
+
this.drawSpecificLabels = function ()
|
1117
|
+
{
|
1118
|
+
//
|
1119
|
+
// If the xaxisLabels option is a string then turn it
|
1120
|
+
// into an array.
|
1121
|
+
//
|
1122
|
+
if (properties.labelsSpecific && properties.labelsSpecific.length) {
|
1123
|
+
if (typeof properties.labelsSpecific === 'string') {
|
1124
|
+
properties.labelsSpecific = RGraph.arrayPad({
|
1125
|
+
array: [],
|
1126
|
+
length: properties.labelsCount,
|
1127
|
+
value: properties.labelsSpecific
|
1128
|
+
});
|
1129
|
+
}
|
1130
|
+
|
1131
|
+
// Label substitution
|
1132
|
+
//
|
1133
|
+
for (var i=0; i<properties.labelsSpecific; ++i) {
|
1134
|
+
properties.labelsSpecific[i] = RGraph.labelSubstitution({
|
1135
|
+
object: this,
|
1136
|
+
text: properties.labelsSpecific[i],
|
1137
|
+
index: i,
|
1138
|
+
value: typeof this.value === 'object' && typeof this.value[i] === 'number' ? this.value[i] : this.value,
|
1139
|
+
decimals: properties.labelsSpecificFormattedDecimals || 0,
|
1140
|
+
unitsPre: properties.labelsSpecificFormattedUnitsPre || '',
|
1141
|
+
unitsPost: properties.labelsSpecificFormattedUnitsPost || '',
|
1142
|
+
thousand: properties.labelsSpecificFormattedThousand || ',',
|
1143
|
+
point: properties.labelsSpecificFormattedPoint || '.'
|
1144
|
+
});
|
1145
|
+
}
|
1146
|
+
}
|
1147
|
+
|
1148
|
+
|
1149
|
+
var labels = properties.labelsSpecific;
|
1150
|
+
|
1151
|
+
if (labels) {
|
1152
|
+
|
1153
|
+
var valign = (properties.labelsPosition == 'top' ? 'bottom' : 'top'),
|
1154
|
+
step = this.width / (labels.length - 1),
|
1155
|
+
offsetx = properties.labelsOffsetx,
|
1156
|
+
offsety = properties.labelsOffsety
|
1157
|
+
|
1158
|
+
var textConf = RGraph.getTextConf({
|
1159
|
+
object: this,
|
1160
|
+
prefix: 'labels'
|
1161
|
+
});
|
1162
|
+
|
1163
|
+
this.context.beginPath();
|
1164
|
+
this.context.fillStyle = properties.textColor;
|
1165
|
+
for (var i=0; i<labels.length; ++i) {
|
1166
|
+
RGraph.text({
|
1167
|
+
|
1168
|
+
object: this,
|
1169
|
+
|
1170
|
+
font: textConf.font,
|
1171
|
+
size: textConf.size,
|
1172
|
+
color: textConf.color,
|
1173
|
+
bold: textConf.bold,
|
1174
|
+
italic: textConf.italic,
|
1175
|
+
|
1176
|
+
x: this.marginLeft + (step * i) + offsetx,
|
1177
|
+
y: properties.labelsPosition == 'top'
|
1178
|
+
? this.marginTop - 7 + offsety
|
1179
|
+
: this.canvas.height - this.marginBottom + 7 + offsety,
|
1180
|
+
text: labels[i],
|
1181
|
+
valign: valign,
|
1182
|
+
halign: 'center',
|
1183
|
+
tag: 'labels.specific',
|
1184
|
+
cssClass: properties.labelsSpecific
|
1185
|
+
? RGraph.getLabelsCSSClassName({
|
1186
|
+
object: this,
|
1187
|
+
name: 'labelsClass',
|
1188
|
+
index: i
|
1189
|
+
})
|
1190
|
+
: ''
|
1191
|
+
});
|
1192
|
+
}
|
1193
|
+
this.context.fill();
|
1194
|
+
}
|
1195
|
+
};
|
1196
|
+
|
1197
|
+
|
1198
|
+
|
1199
|
+
|
1200
|
+
|
1201
|
+
|
1202
|
+
|
1203
|
+
|
1204
|
+
//
|
1205
|
+
// This function returns the appropriate X coordinate for the given value
|
1206
|
+
//
|
1207
|
+
// @param int value The value you want the coordinate for
|
1208
|
+
// @returm int The coordinate
|
1209
|
+
//
|
1210
|
+
this.getXCoord = function (value)
|
1211
|
+
{
|
1212
|
+
var min = this.min;
|
1213
|
+
|
1214
|
+
if (value < min || value > this.max) {
|
1215
|
+
return null;
|
1216
|
+
}
|
1217
|
+
|
1218
|
+
var barWidth = this.canvas.width - this.marginLeft - this.marginRight;
|
1219
|
+
var coord = ((value - min) / (this.max - min)) * barWidth;
|
1220
|
+
coord = this.marginLeft + coord;
|
1221
|
+
|
1222
|
+
return coord;
|
1223
|
+
};
|
1224
|
+
|
1225
|
+
|
1226
|
+
|
1227
|
+
|
1228
|
+
|
1229
|
+
|
1230
|
+
|
1231
|
+
|
1232
|
+
//
|
1233
|
+
// This returns true/false as to whether the cursor is over the chart area.
|
1234
|
+
// The cursor does not necessarily have to be over the bar itself.
|
1235
|
+
//
|
1236
|
+
this.overChartArea = function (e)
|
1237
|
+
{
|
1238
|
+
var mouseXY = RGraph.getMouseXY(e);
|
1239
|
+
var mouseX = mouseXY[0];
|
1240
|
+
var mouseY = mouseXY[1];
|
1241
|
+
|
1242
|
+
if ( mouseX >= this.marginLeft
|
1243
|
+
&& mouseX <= (this.canvas.width - this.marginRight)
|
1244
|
+
&& mouseY >= this.marginTop
|
1245
|
+
&& mouseY <= (this.canvas.height - this.marginBottom)
|
1246
|
+
) {
|
1247
|
+
|
1248
|
+
return true;
|
1249
|
+
}
|
1250
|
+
|
1251
|
+
return false;
|
1252
|
+
};
|
1253
|
+
|
1254
|
+
|
1255
|
+
|
1256
|
+
|
1257
|
+
|
1258
|
+
|
1259
|
+
|
1260
|
+
|
1261
|
+
//
|
1262
|
+
//
|
1263
|
+
//
|
1264
|
+
this.parseColors = function ()
|
1265
|
+
{
|
1266
|
+
// Save the original colors so that they can be restored when the canvas is reset
|
1267
|
+
if (this.original_colors.length === 0) {
|
1268
|
+
this.original_colors.colors = RGraph.arrayClone(properties.colors);
|
1269
|
+
this.original_colors.tickmarksColor = RGraph.arrayClone(properties.tickmarksColor);
|
1270
|
+
this.original_colors.colorsStrokeInner = RGraph.arrayClone(properties.colorsStrokeInner);
|
1271
|
+
this.original_colors.colorsStrokeOuter = RGraph.arrayClone(properties.colorsStrokeOuter);
|
1272
|
+
this.original_colors.highlightFill = RGraph.arrayClone(properties.highlightFill);
|
1273
|
+
this.original_colors.highlightStroke = RGraph.arrayClone(properties.highlightStroke);
|
1274
|
+
this.original_colors.highlightColor = RGraph.arrayClone(properties.highlightColor);
|
1275
|
+
}
|
1276
|
+
|
1277
|
+
|
1278
|
+
|
1279
|
+
|
1280
|
+
var colors = properties.colors;
|
1281
|
+
|
1282
|
+
for (var i=0; i<colors.length; ++i) {
|
1283
|
+
colors[i] = this.parseSingleColorForGradient(colors[i]);
|
1284
|
+
}
|
1285
|
+
|
1286
|
+
properties.tickmarksColor = this.parseSingleColorForGradient(properties.tickmarksColor);
|
1287
|
+
properties.colorsStrokeInner = this.parseSingleColorForGradient(properties.colorsStrokeInner);
|
1288
|
+
properties.colorsStrokeOuter = this.parseSingleColorForGradient(properties.colorsStrokeOuter);
|
1289
|
+
properties.highlightFill = this.parseSingleColorForGradient(properties.highlightFill);
|
1290
|
+
properties.highlightStroke = this.parseSingleColorForGradient(properties.highlightStroke);
|
1291
|
+
properties.backgroundColor = this.parseSingleColorForGradient(properties.backgroundColor);
|
1292
|
+
};
|
1293
|
+
|
1294
|
+
|
1295
|
+
|
1296
|
+
|
1297
|
+
|
1298
|
+
|
1299
|
+
|
1300
|
+
|
1301
|
+
//
|
1302
|
+
// Use this function to reset the object to the post-constructor state. Eg reset colors if
|
1303
|
+
// need be etc
|
1304
|
+
//
|
1305
|
+
this.reset = function ()
|
1306
|
+
{
|
1307
|
+
};
|
1308
|
+
|
1309
|
+
|
1310
|
+
|
1311
|
+
|
1312
|
+
|
1313
|
+
|
1314
|
+
|
1315
|
+
|
1316
|
+
//
|
1317
|
+
// This parses a single color value
|
1318
|
+
//
|
1319
|
+
this.parseSingleColorForGradient = function (color)
|
1320
|
+
{
|
1321
|
+
if (!color || typeof color != 'string') {
|
1322
|
+
return color;
|
1323
|
+
}
|
1324
|
+
|
1325
|
+
if (color.match(/^gradient\((.*)\)$/i)) {
|
1326
|
+
|
1327
|
+
// Allow for JSON gradients
|
1328
|
+
if (color.match(/^gradient\(({.*})\)$/i)) {
|
1329
|
+
return RGraph.parseJSONGradient({object: this, def: RegExp.$1});
|
1330
|
+
}
|
1331
|
+
|
1332
|
+
var parts = RegExp.$1.split(':');
|
1333
|
+
|
1334
|
+
// Create the gradient
|
1335
|
+
var grad = this.context.createLinearGradient(
|
1336
|
+
properties.marginLeft,
|
1337
|
+
0,
|
1338
|
+
this.canvas.width - properties.marginRight,
|
1339
|
+
0
|
1340
|
+
);
|
1341
|
+
|
1342
|
+
var diff = 1 / (parts.length - 1);
|
1343
|
+
|
1344
|
+
grad.addColorStop(0, RGraph.trim(parts[0]));
|
1345
|
+
|
1346
|
+
for (var j=1; j<parts.length; ++j) {
|
1347
|
+
grad.addColorStop(j * diff, RGraph.trim(parts[j]));
|
1348
|
+
}
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
return grad ? grad : color;
|
1352
|
+
};
|
1353
|
+
|
1354
|
+
|
1355
|
+
|
1356
|
+
|
1357
|
+
|
1358
|
+
|
1359
|
+
|
1360
|
+
|
1361
|
+
//
|
1362
|
+
// Draws the bevel effect
|
1363
|
+
//
|
1364
|
+
this.drawBevel = function ()
|
1365
|
+
{
|
1366
|
+
// In case of multiple segments - this adds up all the lengths
|
1367
|
+
for (var i=0,len=0; i<this.coords.length; ++i) len += this.coords[i][2];
|
1368
|
+
|
1369
|
+
this.context.save();
|
1370
|
+
// Draw a path to clip to
|
1371
|
+
this.context.beginPath();
|
1372
|
+
this.context.rect(
|
1373
|
+
this.coords[0][0],
|
1374
|
+
this.coords[0][1],
|
1375
|
+
len,
|
1376
|
+
this.coords[0][3]
|
1377
|
+
);
|
1378
|
+
this.context.clip();
|
1379
|
+
|
1380
|
+
this.context.save();
|
1381
|
+
// Draw a path to clip to
|
1382
|
+
this.context.beginPath();
|
1383
|
+
this.drawCurvedBar({
|
1384
|
+
x: this.coords[0][0],
|
1385
|
+
y: this.coords[0][1],
|
1386
|
+
width: len,
|
1387
|
+
height: this.coords[0][3]
|
1388
|
+
});
|
1389
|
+
this.context.clip();
|
1390
|
+
|
1391
|
+
// Now draw the rect with a shadow
|
1392
|
+
this.context.beginPath();
|
1393
|
+
|
1394
|
+
this.context.shadowColor = 'black';
|
1395
|
+
this.context.shadowOffsetX = 0;
|
1396
|
+
this.context.shadowOffsetY = 0;
|
1397
|
+
this.context.shadowBlur = 15;
|
1398
|
+
|
1399
|
+
this.context.lineWidth = 2;
|
1400
|
+
|
1401
|
+
this.drawCurvedBar({
|
1402
|
+
x: this.coords[0][0] - 51,
|
1403
|
+
y: this.coords[0][1] - 1,
|
1404
|
+
width: len + 52,
|
1405
|
+
height: this.coords[0][3] + 2
|
1406
|
+
});
|
1407
|
+
|
1408
|
+
this.context.stroke();
|
1409
|
+
|
1410
|
+
this.context.restore();
|
1411
|
+
this.context.restore();
|
1412
|
+
};
|
1413
|
+
|
1414
|
+
|
1415
|
+
|
1416
|
+
|
1417
|
+
|
1418
|
+
|
1419
|
+
|
1420
|
+
|
1421
|
+
//
|
1422
|
+
// Draw the titles
|
1423
|
+
//
|
1424
|
+
this.drawTitle = function ()
|
1425
|
+
{
|
1426
|
+
RGraph.drawTitle(this);
|
1427
|
+
};
|
1428
|
+
|
1429
|
+
|
1430
|
+
|
1431
|
+
|
1432
|
+
|
1433
|
+
|
1434
|
+
|
1435
|
+
|
1436
|
+
//
|
1437
|
+
// This function handles highlighting an entire data-series for the interactive
|
1438
|
+
// key
|
1439
|
+
//
|
1440
|
+
// @param int index The index of the data series to be highlighted
|
1441
|
+
//
|
1442
|
+
this.interactiveKeyHighlight = function (index)
|
1443
|
+
{
|
1444
|
+
var coords = this.coords[index];
|
1445
|
+
|
1446
|
+
this.context.beginPath();
|
1447
|
+
|
1448
|
+
this.context.strokeStyle = properties.keyInteractiveHighlightChartStroke;
|
1449
|
+
this.context.lineWidth = 2;
|
1450
|
+
this.context.fillStyle = properties.keyInteractiveHighlightChartFill;
|
1451
|
+
|
1452
|
+
this.context.rect(coords[0] - 0.5, coords[1] - 0.5, coords[2] + 1, coords[3] + 1);
|
1453
|
+
this.context.fill();
|
1454
|
+
this.context.stroke();
|
1455
|
+
|
1456
|
+
// Reset the linewidth
|
1457
|
+
this.context.lineWidth = 1;
|
1458
|
+
};
|
1459
|
+
|
1460
|
+
|
1461
|
+
|
1462
|
+
|
1463
|
+
|
1464
|
+
|
1465
|
+
|
1466
|
+
|
1467
|
+
//
|
1468
|
+
// Using a function to add events makes it easier to facilitate method chaining
|
1469
|
+
//
|
1470
|
+
// @param string type The type of even to add
|
1471
|
+
// @param function func
|
1472
|
+
//
|
1473
|
+
this.on = function (type, func)
|
1474
|
+
{
|
1475
|
+
if (type.substr(0,2) !== 'on') {
|
1476
|
+
type = 'on' + type;
|
1477
|
+
}
|
1478
|
+
|
1479
|
+
if (typeof this[type] !== 'function') {
|
1480
|
+
this[type] = func;
|
1481
|
+
} else {
|
1482
|
+
RGraph.addCustomEventListener(this, type, func);
|
1483
|
+
}
|
1484
|
+
|
1485
|
+
return this;
|
1486
|
+
};
|
1487
|
+
|
1488
|
+
|
1489
|
+
|
1490
|
+
|
1491
|
+
|
1492
|
+
|
1493
|
+
|
1494
|
+
|
1495
|
+
//
|
1496
|
+
// Draws a bar with a curved end.
|
1497
|
+
//
|
1498
|
+
// DOESN'T DRAW A CURVED BAR ANY MORE - JUST A REGULAR SQUARE ENDED BAR
|
1499
|
+
//
|
1500
|
+
// @param object opt The coords and colours
|
1501
|
+
//
|
1502
|
+
this.drawCurvedBar = function (opt)
|
1503
|
+
{
|
1504
|
+
this.path(
|
1505
|
+
'b r % % % %',
|
1506
|
+
opt.x, opt.y, opt.width, opt.height
|
1507
|
+
);
|
1508
|
+
|
1509
|
+
if (opt.stroke) {
|
1510
|
+
this.context.strokeStyle = opt.stroke;
|
1511
|
+
this.context.stroke();
|
1512
|
+
}
|
1513
|
+
|
1514
|
+
if (opt.fill) {
|
1515
|
+
this.context.fillStyle = opt.fill;
|
1516
|
+
this.context.fill();
|
1517
|
+
}
|
1518
|
+
}
|
1519
|
+
|
1520
|
+
|
1521
|
+
|
1522
|
+
|
1523
|
+
|
1524
|
+
|
1525
|
+
|
1526
|
+
|
1527
|
+
//
|
1528
|
+
// This function runs once only
|
1529
|
+
// (put at the end of the file (before any effects))
|
1530
|
+
//
|
1531
|
+
this.firstDrawFunc = function ()
|
1532
|
+
{
|
1533
|
+
};
|
1534
|
+
|
1535
|
+
|
1536
|
+
|
1537
|
+
|
1538
|
+
|
1539
|
+
|
1540
|
+
|
1541
|
+
|
1542
|
+
//
|
1543
|
+
// HProgress Grow effect (which is also the VPogress Grow effect)
|
1544
|
+
//
|
1545
|
+
// @param object obj The chart object
|
1546
|
+
//
|
1547
|
+
this.grow = function ()
|
1548
|
+
{
|
1549
|
+
// Cancel any stop request if one is pending
|
1550
|
+
this.cancelStopAnimation();
|
1551
|
+
|
1552
|
+
var obj = this;
|
1553
|
+
var canvas = obj.canvas;
|
1554
|
+
var context = obj.context;
|
1555
|
+
var initial_value = obj.currentValue;
|
1556
|
+
var opt = arguments[0] || {};
|
1557
|
+
var numFrames = opt.frames || 30;
|
1558
|
+
var frame = 0
|
1559
|
+
var callback = arguments[1] || function () {};
|
1560
|
+
|
1561
|
+
if (typeof obj.value === 'object') {
|
1562
|
+
|
1563
|
+
if (RGraph.isNull(obj.currentValue)) {
|
1564
|
+
obj.currentValue = [];
|
1565
|
+
for (var i=0,len=obj.value.length; i<len; ++i) {
|
1566
|
+
obj.currentValue[i] = 0;
|
1567
|
+
}
|
1568
|
+
}
|
1569
|
+
|
1570
|
+
var diff = [];
|
1571
|
+
var increment = [];
|
1572
|
+
|
1573
|
+
for (var i=0,len=obj.value.length; i<len; ++i) {
|
1574
|
+
diff[i] = obj.value[i] - Number(obj.currentValue[i]);
|
1575
|
+
increment[i] = diff[i] / numFrames;
|
1576
|
+
}
|
1577
|
+
|
1578
|
+
if (initial_value == null) {
|
1579
|
+
initial_value = [];
|
1580
|
+
for (var i=0,len=obj.value.length; i<len; ++i) {
|
1581
|
+
initial_value[i] = 0;
|
1582
|
+
}
|
1583
|
+
}
|
1584
|
+
|
1585
|
+
} else {
|
1586
|
+
|
1587
|
+
var diff = obj.value - Number(obj.currentValue);
|
1588
|
+
var increment = diff / numFrames;
|
1589
|
+
}
|
1590
|
+
|
1591
|
+
|
1592
|
+
|
1593
|
+
|
1594
|
+
|
1595
|
+
|
1596
|
+
function iterator ()
|
1597
|
+
{
|
1598
|
+
if (obj.stopAnimationRequested) {
|
1599
|
+
|
1600
|
+
// Reset the flag
|
1601
|
+
obj.stopAnimationRequested = false;
|
1602
|
+
|
1603
|
+
return;
|
1604
|
+
}
|
1605
|
+
|
1606
|
+
frame++;
|
1607
|
+
|
1608
|
+
if (frame <= numFrames) {
|
1609
|
+
|
1610
|
+
if (typeof obj.value == 'object') {
|
1611
|
+
obj.value = [];
|
1612
|
+
for (var i=0,len=initial_value.length; i<len; ++i) {
|
1613
|
+
obj.value[i] = initial_value[i] + (increment[i] * frame);
|
1614
|
+
}
|
1615
|
+
} else {
|
1616
|
+
obj.value = initial_value + (increment * frame);
|
1617
|
+
}
|
1618
|
+
|
1619
|
+
RGraph.clear(obj.canvas);
|
1620
|
+
RGraph.redrawCanvas(obj.canvas);
|
1621
|
+
|
1622
|
+
RGraph.Effects.updateCanvas(iterator);
|
1623
|
+
} else {
|
1624
|
+
callback();
|
1625
|
+
}
|
1626
|
+
}
|
1627
|
+
|
1628
|
+
iterator();
|
1629
|
+
|
1630
|
+
return this;
|
1631
|
+
};
|
1632
|
+
|
1633
|
+
|
1634
|
+
|
1635
|
+
|
1636
|
+
|
1637
|
+
|
1638
|
+
|
1639
|
+
|
1640
|
+
//
|
1641
|
+
// Couple of functions that allow you to control the
|
1642
|
+
// animation effect
|
1643
|
+
//
|
1644
|
+
this.stopAnimation = function ()
|
1645
|
+
{
|
1646
|
+
this.stopAnimationRequested = true;
|
1647
|
+
};
|
1648
|
+
|
1649
|
+
this.cancelStopAnimation = function ()
|
1650
|
+
{
|
1651
|
+
this.stopAnimationRequested = false;
|
1652
|
+
};
|
1653
|
+
|
1654
|
+
|
1655
|
+
|
1656
|
+
|
1657
|
+
|
1658
|
+
|
1659
|
+
|
1660
|
+
|
1661
|
+
//
|
1662
|
+
// A worker function that handles Bar chart specific tooltip substitutions
|
1663
|
+
//
|
1664
|
+
this.tooltipSubstitutions = function (opt)
|
1665
|
+
{
|
1666
|
+
var values = typeof this.value === 'number' ? [this.value] : this.value;
|
1667
|
+
|
1668
|
+
//
|
1669
|
+
// Return the values to the user
|
1670
|
+
//
|
1671
|
+
return {
|
1672
|
+
index: opt.index,
|
1673
|
+
dataset: 0,
|
1674
|
+
sequentialIndex: opt.index,
|
1675
|
+
value: typeof this.value === 'number' ? this.value : this.value[opt.index],
|
1676
|
+
values: typeof this.value === 'number' ? [this.value] : [this.value[opt.index]]
|
1677
|
+
};
|
1678
|
+
};
|
1679
|
+
|
1680
|
+
|
1681
|
+
|
1682
|
+
|
1683
|
+
|
1684
|
+
|
1685
|
+
|
1686
|
+
|
1687
|
+
//
|
1688
|
+
// A worker function that returns the correct color/label/value
|
1689
|
+
//
|
1690
|
+
// @param object specific The indexes that are applicable
|
1691
|
+
// @param number index The appropriate index
|
1692
|
+
//
|
1693
|
+
this.tooltipsFormattedCustom = function (specific, index)
|
1694
|
+
{
|
1695
|
+
var color = properties.colors[specific.index];
|
1696
|
+
var label = RGraph.isString(properties.tooltipsFormattedKeyLabels[specific.index]) ? properties.tooltipsFormattedKeyLabels[specific.index] : '';
|
1697
|
+
|
1698
|
+
if (properties.tooltipsFormattedKeyColors && properties.tooltipsFormattedKeyColors[specific.index]) {
|
1699
|
+
color = properties.tooltipsFormattedKeyColors[specific.index];
|
1700
|
+
}
|
1701
|
+
|
1702
|
+
return {
|
1703
|
+
label: label,
|
1704
|
+
color: color
|
1705
|
+
};
|
1706
|
+
};
|
1707
|
+
|
1708
|
+
|
1709
|
+
|
1710
|
+
|
1711
|
+
|
1712
|
+
|
1713
|
+
|
1714
|
+
|
1715
|
+
//
|
1716
|
+
// This allows for static tooltip positioning
|
1717
|
+
//
|
1718
|
+
this.positionTooltipStatic = function (args)
|
1719
|
+
{
|
1720
|
+
var obj = args.object,
|
1721
|
+
e = args.event,
|
1722
|
+
tooltip = args.tooltip,
|
1723
|
+
index = args.index,
|
1724
|
+
canvasXY = RGraph.getCanvasXY(obj.canvas)
|
1725
|
+
coords = this.coords[args.index];
|
1726
|
+
|
1727
|
+
// Position the tooltip in the X direction
|
1728
|
+
args.tooltip.style.left = (
|
1729
|
+
canvasXY[0] // The X coordinate of the canvas
|
1730
|
+
+ coords[0] // The X coordinate of the bar on the chart
|
1731
|
+
- (tooltip.offsetWidth / 2) // Subtract half of the tooltip width
|
1732
|
+
+ (coords[2] / 2) // Add half of the bar width
|
1733
|
+
+ obj.properties.tooltipsOffsetx // Add any user defined offset
|
1734
|
+
) + 'px';
|
1735
|
+
|
1736
|
+
args.tooltip.style.top = (
|
1737
|
+
canvasXY[1] // The Y coordinate of the canvas
|
1738
|
+
+ coords[1] // The Y coordinate of the bar on the chart
|
1739
|
+
- tooltip.offsetHeight // The height of the tooltip
|
1740
|
+
- 10 // An arbitrary amount
|
1741
|
+
+ obj.properties.tooltipsOffsety // Add any user defined offset
|
1742
|
+
) + 'px';
|
1743
|
+
|
1744
|
+
|
1745
|
+
|
1746
|
+
// If the top of the tooltip is off the top of the page
|
1747
|
+
// then move the tooltip down
|
1748
|
+
if(parseFloat(args.tooltip.style.top) < 0) {
|
1749
|
+
args.tooltip.style.top = parseFloat(args.tooltip.style.top) + 20 + 'px';
|
1750
|
+
}
|
1751
|
+
};
|
1752
|
+
|
1753
|
+
|
1754
|
+
|
1755
|
+
|
1756
|
+
|
1757
|
+
|
1758
|
+
|
1759
|
+
|
1760
|
+
//
|
1761
|
+
// This returns the relevant value for the formatted key
|
1762
|
+
// macro %{value}. THIS VALUE SHOULD NOT BE FORMATTED.
|
1763
|
+
//
|
1764
|
+
// @param number index The index in the dataset to get
|
1765
|
+
// the value for
|
1766
|
+
//
|
1767
|
+
this.getKeyValue = function (index)
|
1768
|
+
{
|
1769
|
+
return RGraph.isArray(this.properties.keyFormattedValueSpecific) && RGraph.isNumber(this.properties.keyFormattedValueSpecific[index])
|
1770
|
+
? this.properties.keyFormattedValueSpecific[index]
|
1771
|
+
: (RGraph.isArray(this.value) ? this.value[index] : this.value);
|
1772
|
+
};
|
1773
|
+
|
1774
|
+
|
1775
|
+
|
1776
|
+
|
1777
|
+
|
1778
|
+
|
1779
|
+
|
1780
|
+
|
1781
|
+
//
|
1782
|
+
// Returns how many data-points there should be when a string
|
1783
|
+
// based key property has been specified. For example, this:
|
1784
|
+
//
|
1785
|
+
// key: '%{property:_labels[%{index}]} %{value_formatted}'
|
1786
|
+
//
|
1787
|
+
// ...depending on how many bits of data ther is might get
|
1788
|
+
// turned into this:
|
1789
|
+
//
|
1790
|
+
// key: [
|
1791
|
+
// '%{property:_labels[%{index}]} %{value_formatted}',
|
1792
|
+
// '%{property:_labels[%{index}]} %{value_formatted}',
|
1793
|
+
// '%{property:_labels[%{index}]} %{value_formatted}',
|
1794
|
+
// '%{property:_labels[%{index}]} %{value_formatted}',
|
1795
|
+
// '%{property:_labels[%{index}]} %{value_formatted}',
|
1796
|
+
// ]
|
1797
|
+
//
|
1798
|
+
// ... ie in that case there would be 4 data-points so the
|
1799
|
+
// template is repeated 4 times.
|
1800
|
+
//
|
1801
|
+
this.getKeyNumDatapoints = function ()
|
1802
|
+
{
|
1803
|
+
return this.value.length;
|
1804
|
+
};
|
1805
|
+
|
1806
|
+
|
1807
|
+
|
1808
|
+
|
1809
|
+
|
1810
|
+
|
1811
|
+
|
1812
|
+
|
1813
|
+
//
|
1814
|
+
// Register the object for redrawing
|
1815
|
+
//
|
1816
|
+
RGraph.register(this);
|
1817
|
+
|
1818
|
+
|
1819
|
+
|
1820
|
+
|
1821
|
+
|
1822
|
+
|
1823
|
+
|
1824
|
+
|
1825
|
+
//
|
1826
|
+
// This is the 'end' of the constructor so if the first argument
|
1827
|
+
// contains configuration data - handle that.
|
1828
|
+
//
|
1829
|
+
RGraph.parseObjectStyleConfig(this, conf.options);
|
1830
|
+
};
|