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