rgraph-rails 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +0 -1
- data/README.md +3 -3
- data/lib/rgraph-rails/version.rb +1 -1
- data/vendor/assets/javascripts/RGraph.bar.js +239 -3764
- data/vendor/assets/javascripts/RGraph.bipolar.js +115 -1986
- data/vendor/assets/javascripts/RGraph.common.annotate.js +35 -399
- data/vendor/assets/javascripts/RGraph.common.context.js +30 -600
- data/vendor/assets/javascripts/RGraph.common.core.js +403 -5187
- data/vendor/assets/javascripts/RGraph.common.csv.js +19 -275
- data/vendor/assets/javascripts/RGraph.common.deprecated.js +35 -454
- data/vendor/assets/javascripts/RGraph.common.dynamic.js +84 -1189
- data/vendor/assets/javascripts/RGraph.common.effects.js +90 -1548
- data/vendor/assets/javascripts/RGraph.common.key.js +54 -755
- data/vendor/assets/javascripts/RGraph.common.resizing.js +37 -567
- data/vendor/assets/javascripts/RGraph.common.sheets.js +29 -356
- data/vendor/assets/javascripts/RGraph.common.tooltips.js +32 -614
- data/vendor/assets/javascripts/RGraph.common.zoom.js +14 -223
- data/vendor/assets/javascripts/RGraph.cornergauge.js +71 -0
- data/vendor/assets/javascripts/RGraph.drawing.background.js +35 -620
- data/vendor/assets/javascripts/RGraph.drawing.circle.js +35 -576
- data/vendor/assets/javascripts/RGraph.drawing.image.js +52 -807
- data/vendor/assets/javascripts/RGraph.drawing.marker1.js +41 -717
- data/vendor/assets/javascripts/RGraph.drawing.marker2.js +37 -668
- data/vendor/assets/javascripts/RGraph.drawing.marker3.js +36 -563
- data/vendor/assets/javascripts/RGraph.drawing.poly.js +40 -608
- data/vendor/assets/javascripts/RGraph.drawing.rect.js +35 -597
- data/vendor/assets/javascripts/RGraph.drawing.text.js +34 -642
- data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +50 -809
- data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +51 -856
- data/vendor/assets/javascripts/RGraph.fuel.js +58 -964
- data/vendor/assets/javascripts/RGraph.funnel.js +55 -984
- data/vendor/assets/javascripts/RGraph.gantt.js +75 -1241
- data/vendor/assets/javascripts/RGraph.gauge.js +87 -1397
- data/vendor/assets/javascripts/RGraph.hbar.js +143 -2376
- data/vendor/assets/javascripts/RGraph.hprogress.js +80 -1397
- data/vendor/assets/javascripts/RGraph.line.js +241 -4162
- data/vendor/assets/javascripts/RGraph.meter.js +74 -1278
- metadata +3 -30
- data/vendor/assets/images/bg.png +0 -0
- data/vendor/assets/images/bullet.png +0 -0
- data/vendor/assets/images/facebook-large.png +0 -0
- data/vendor/assets/images/google-plus-large.png +0 -0
- data/vendor/assets/images/logo.png +0 -0
- data/vendor/assets/images/meter-image-sd-needle.png +0 -0
- data/vendor/assets/images/meter-image-sd.png +0 -0
- data/vendor/assets/images/meter-sketch-needle.png +0 -0
- data/vendor/assets/images/meter-sketch.png +0 -0
- data/vendor/assets/images/odometer-background.png +0 -0
- data/vendor/assets/images/rgraph.jpg +0 -0
- data/vendor/assets/images/title.png +0 -0
- data/vendor/assets/images/twitter-large.png +0 -0
- data/vendor/assets/javascripts/RGraph.modaldialog.js +0 -301
- data/vendor/assets/javascripts/RGraph.odo.js +0 -1265
- data/vendor/assets/javascripts/RGraph.pie.js +0 -2272
- data/vendor/assets/javascripts/RGraph.radar.js +0 -1847
- data/vendor/assets/javascripts/RGraph.rose.js +0 -1877
- data/vendor/assets/javascripts/RGraph.rscatter.js +0 -1425
- data/vendor/assets/javascripts/RGraph.scatter.js +0 -2970
- data/vendor/assets/javascripts/RGraph.semicircularprogress.js +0 -1015
- data/vendor/assets/javascripts/RGraph.thermometer.js +0 -1129
- data/vendor/assets/javascripts/RGraph.vprogress.js +0 -1452
- data/vendor/assets/javascripts/RGraph.waterfall.js +0 -1252
- data/vendor/assets/javascripts/financial-data.js +0 -1067
- data/vendor/assets/stylesheets/ModalDialog.css +0 -90
- data/vendor/assets/stylesheets/animations.css +0 -3347
- data/vendor/assets/stylesheets/website.css +0 -446
@@ -1,857 +1,52 @@
|
|
1
|
-
// version: 2016-06-04
|
2
|
-
/**
|
3
|
-
* o--------------------------------------------------------------------------------o
|
4
|
-
* | This file is part of the RGraph package - you can learn more at: |
|
5
|
-
* | |
|
6
|
-
* | http://www.rgraph.net |
|
7
|
-
* | |
|
8
|
-
* | RGraph is dual licensed under the Open Source GPL (General Public License) |
|
9
|
-
* | v2.0 license and a commercial license which means that you're not bound by |
|
10
|
-
* | the terms of the GPL. The commercial license is just 99 GBP and you can |
|
11
|
-
* | read about it here: |
|
12
|
-
* | http://www.rgraph.net/license |
|
13
|
-
* o--------------------------------------------------------------------------------o
|
14
|
-
*/
|
15
1
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
*/
|
68
|
-
this.type = 'drawing.yaxis';
|
69
|
-
|
70
|
-
|
71
|
-
/**
|
72
|
-
* This facilitates easy object identification, and should always be true
|
73
|
-
*/
|
74
|
-
this.isRGraph = true;
|
75
|
-
|
76
|
-
|
77
|
-
/**
|
78
|
-
* This adds a uid to the object that you can use for identification purposes
|
79
|
-
*/
|
80
|
-
this.uid = RGraph.CreateUID();
|
81
|
-
|
82
|
-
|
83
|
-
/**
|
84
|
-
* This adds a UID to the canvas for identification purposes
|
85
|
-
*/
|
86
|
-
this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.CreateUID();
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
/**
|
91
|
-
* Some example background properties
|
92
|
-
*/
|
93
|
-
this.properties =
|
94
|
-
{
|
95
|
-
'chart.gutter.top': 25,
|
96
|
-
'chart.gutter.bottom': 30,
|
97
|
-
'chart.min': 0,
|
98
|
-
'chart.max': null,
|
99
|
-
'chart.colors': ['black'],
|
100
|
-
'chart.title': '',
|
101
|
-
'chart.title.color': null,
|
102
|
-
'chart.numticks': 5,
|
103
|
-
'chart.numlabels': 5,
|
104
|
-
'chart.labels.specific': null,
|
105
|
-
'chart.text.font': 'Segoe UI, Arial, Verdana, sans-serif',
|
106
|
-
'chart.text.size': 12,
|
107
|
-
'chart.text.color': null,
|
108
|
-
'chart.text.accessible': true,
|
109
|
-
'chart.text.accessible.overflow':'visible',
|
110
|
-
'chart.text.accessible.pointerevents': false,
|
111
|
-
'chart.align': 'left',
|
112
|
-
'hart.scale.formatter': null,
|
113
|
-
'chart.scale.point': '.',
|
114
|
-
'chart.scale.decimals': 0,
|
115
|
-
'chart.scale.decimals': 0,
|
116
|
-
'chart.scale.point': '.',
|
117
|
-
'chart.scale.invert': false,
|
118
|
-
'chart.scale.zerostart': true,
|
119
|
-
'chart.scale.visible': true,
|
120
|
-
'chart.units.pre': '',
|
121
|
-
'chart.units.post': '',
|
122
|
-
'chart.linewidth': 1,
|
123
|
-
'chart.noendtick.top': false,
|
124
|
-
'chart.noendtick.bottom': false,
|
125
|
-
'chart.noyaxis': false,
|
126
|
-
'chart.tooltips': null,
|
127
|
-
'chart.tooltips.effect': 'fade',
|
128
|
-
'chart.tooltips.css.class':'RGraph_tooltip',
|
129
|
-
'chart.tooltips.event': 'onclick',
|
130
|
-
'chart.xaxispos': 'bottom',
|
131
|
-
'chart.events.click': null,
|
132
|
-
'chart.events.mousemove': null,
|
133
|
-
'chart.clearto': 'rgba(0,0,0,0)'
|
134
|
-
}
|
135
|
-
|
136
|
-
|
137
|
-
/**
|
138
|
-
* A simple check that the browser has canvas support
|
139
|
-
*/
|
140
|
-
if (!this.canvas) {
|
141
|
-
alert('[DRAWING.YAXIS] No canvas support');
|
142
|
-
return;
|
143
|
-
}
|
144
|
-
|
145
|
-
/**
|
146
|
-
* Create the dollar object so that functions can be added to them
|
147
|
-
*/
|
148
|
-
this.$0 = {};
|
149
|
-
|
150
|
-
|
151
|
-
/**
|
152
|
-
* Translate half a pixel for antialiasing purposes - but only if it hasn't beeen
|
153
|
-
* done already
|
154
|
-
*
|
155
|
-
* ** Could use setTransform() here instead ?
|
156
|
-
*/
|
157
|
-
if (!this.canvas.__rgraph_aa_translated__) {
|
158
|
-
this.context.translate(0.5,0.5);
|
159
|
-
|
160
|
-
this.canvas.__rgraph_aa_translated__ = true;
|
161
|
-
}
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
// Short variable names
|
166
|
-
var RG = RGraph,
|
167
|
-
ca = this.canvas,
|
168
|
-
co = ca.getContext('2d'),
|
169
|
-
prop = this.properties,
|
170
|
-
pa2 = RG.path2,
|
171
|
-
win = window,
|
172
|
-
doc = document,
|
173
|
-
ma = Math
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
/**
|
178
|
-
* "Decorate" the object with the generic effects if the effects library has been included
|
179
|
-
*/
|
180
|
-
if (RG.Effects && typeof RG.Effects.decorate === 'function') {
|
181
|
-
RG.Effects.decorate(this);
|
182
|
-
}
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
/**
|
192
|
-
* A setter method for setting graph properties. It can be used like this: obj.Set('chart.strokestyle', '#666');
|
193
|
-
*
|
194
|
-
* @param name string The name of the property to set
|
195
|
-
* @param value mixed The value of the property
|
196
|
-
*/
|
197
|
-
this.set =
|
198
|
-
this.Set = function (name)
|
199
|
-
{
|
200
|
-
var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
|
201
|
-
|
202
|
-
/**
|
203
|
-
* the number of arguments is only one and it's an
|
204
|
-
* object - parse it for configuration data and return.
|
205
|
-
*/
|
206
|
-
if (arguments.length === 1 && typeof name === 'object') {
|
207
|
-
RG.parseObjectStyleConfig(this, name);
|
208
|
-
return this;
|
209
|
-
}
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
/**
|
216
|
-
* This should be done first - prepend the property name with "chart." if necessary
|
217
|
-
*/
|
218
|
-
if (name.substr(0,6) != 'chart.') {
|
219
|
-
name = 'chart.' + name;
|
220
|
-
}
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
// Convert uppercase letters to dot+lower case letter
|
226
|
-
while(name.match(/([A-Z])/)) {
|
227
|
-
name = name.replace(/([A-Z])/, '.' + RegExp.$1.toLowerCase());
|
228
|
-
}
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
prop[name] = value;
|
236
|
-
|
237
|
-
return this;
|
238
|
-
};
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
/**
|
244
|
-
* A getter method for retrieving graph properties. It can be used like this: obj.Get('chart.strokestyle');
|
245
|
-
*
|
246
|
-
* @param name string The name of the property to get
|
247
|
-
*/
|
248
|
-
this.get =
|
249
|
-
this.Get = function (name)
|
250
|
-
{
|
251
|
-
/**
|
252
|
-
* This should be done first - prepend the property name with "chart." if necessary
|
253
|
-
*/
|
254
|
-
if (name.substr(0,6) != 'chart.') {
|
255
|
-
name = 'chart.' + name;
|
256
|
-
}
|
257
|
-
|
258
|
-
// Convert uppercase letters to dot+lower case letter
|
259
|
-
name = name.replace(/([A-Z])/g, function (str)
|
260
|
-
{
|
261
|
-
return '.' + String(RegExp.$1).toLowerCase()
|
262
|
-
});
|
263
|
-
|
264
|
-
return prop[name.toLowerCase()];
|
265
|
-
};
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
/**
|
271
|
-
* Draws the axes
|
272
|
-
*/
|
273
|
-
this.draw =
|
274
|
-
this.Draw = function ()
|
275
|
-
{
|
276
|
-
/**
|
277
|
-
* Fire the onbeforedraw event
|
278
|
-
*/
|
279
|
-
RG.fireCustomEvent(this, 'onbeforedraw');
|
280
|
-
|
281
|
-
/**
|
282
|
-
* Some defaults
|
283
|
-
*/
|
284
|
-
this.gutterTop = prop['chart.gutter.top'];
|
285
|
-
this.gutterBottom = prop['chart.gutter.bottom'];
|
286
|
-
|
287
|
-
|
288
|
-
/**
|
289
|
-
* Stop this growing uncntrollably
|
290
|
-
*/
|
291
|
-
this.coordsText = [];
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
if (!prop['chart.text.color']) prop['chart.text.color'] = prop['chart.colors'][0];
|
296
|
-
if (!prop['chart.title.color']) prop['chart.title.color'] = prop['chart.colors'][0];
|
297
|
-
|
298
|
-
/**
|
299
|
-
* Parse the colors. This allows for simple gradient syntax
|
300
|
-
*/
|
301
|
-
if (!this.colorsParsed) {
|
302
|
-
|
303
|
-
this.parseColors();
|
304
|
-
|
305
|
-
// Don't want to do this again
|
306
|
-
this.colorsParsed = true;
|
307
|
-
}
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
// DRAW Y AXIS HERE
|
312
|
-
this.drawYAxis();
|
313
|
-
|
314
|
-
|
315
|
-
/**
|
316
|
-
* This installs the event listeners
|
317
|
-
*/
|
318
|
-
RG.InstallEventListeners(this);
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
/**
|
323
|
-
* Fire the onfirstdraw event
|
324
|
-
*/
|
325
|
-
if (this.firstDraw) {
|
326
|
-
RG.fireCustomEvent(this, 'onfirstdraw');
|
327
|
-
this.firstDraw = false;
|
328
|
-
this.firstDrawFunc();
|
329
|
-
}
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
/**
|
335
|
-
* Fire the ondraw event
|
336
|
-
*/
|
337
|
-
RG.FireCustomEvent(this, 'ondraw');
|
338
|
-
|
339
|
-
return this;
|
340
|
-
};
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
/**
|
345
|
-
* Used in chaining. Runs a function there and then - not waiting for
|
346
|
-
* the events to fire (eg the onbeforedraw event)
|
347
|
-
*
|
348
|
-
* @param function func The function to execute
|
349
|
-
*/
|
350
|
-
this.exec = function (func)
|
351
|
-
{
|
352
|
-
func(this);
|
353
|
-
|
354
|
-
return this;
|
355
|
-
};
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
/**
|
361
|
-
* The getObjectByXY() worker method
|
362
|
-
*/
|
363
|
-
this.getObjectByXY = function (e)
|
364
|
-
{
|
365
|
-
if (this.getShape(e)) {
|
366
|
-
return this;
|
367
|
-
}
|
368
|
-
};
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
/**
|
374
|
-
* Not used by the class during creating the axis, but is used by event handlers
|
375
|
-
* to get the coordinates (if any) of the selected shape
|
376
|
-
*
|
377
|
-
* @param object e The event object
|
378
|
-
*/
|
379
|
-
this.getShape = function (e)
|
380
|
-
{
|
381
|
-
var mouseXY = RG.getMouseXY(e);
|
382
|
-
var mouseX = mouseXY[0];
|
383
|
-
var mouseY = mouseXY[1];
|
384
|
-
|
385
|
-
if ( mouseX >= this.x - (prop['chart.align'] == 'right' ? 0 : this.getWidth())
|
386
|
-
&& mouseX <= this.x + (prop['chart.align'] == 'right' ? this.getWidth() : 0)
|
387
|
-
&& mouseY >= this.gutterTop
|
388
|
-
&& mouseY <= (ca.height - this.gutterBottom)
|
389
|
-
) {
|
390
|
-
|
391
|
-
var x = this.x;
|
392
|
-
var y = this.gutterTop;
|
393
|
-
var w = 15;;
|
394
|
-
var h = ca.height - this.gutterTop - this.gutterBottom;
|
395
|
-
|
396
|
-
return {
|
397
|
-
0: this, 1: x, 2: y, 3: w, 4: h, 5: 0,
|
398
|
-
'object': this, 'x': x, 'y': y, 'width': w, 'height': h, 'index': 0, 'tooltip': prop['chart.tooltips'] ? prop['chart.tooltips'][0] : null
|
399
|
-
};
|
400
|
-
}
|
401
|
-
|
402
|
-
return null;
|
403
|
-
};
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
/**
|
409
|
-
* This function positions a tooltip when it is displayed
|
410
|
-
*
|
411
|
-
* @param obj object The chart object
|
412
|
-
* @param int x The X coordinate specified for the tooltip
|
413
|
-
* @param int y The Y coordinate specified for the tooltip
|
414
|
-
* @param objec tooltip The tooltips DIV element
|
415
|
-
*/
|
416
|
-
this.positionTooltip = function (obj, x, y, tooltip, idx)
|
417
|
-
{
|
418
|
-
// If there's multiple charts on the canvas they leave unknown font settings
|
419
|
-
co.font = prop['chart.text.size'] + ' ' + prop['chart.text.font'];
|
420
|
-
|
421
|
-
var coordW = co.measureText(prop['chart.max'].toFixed(prop['chart.scale.decimals'])).width;
|
422
|
-
var coordX = obj.x - coordW;
|
423
|
-
var coordY = obj.gutterTop;
|
424
|
-
var coordH = ca.height - obj.gutterTop - obj.gutterBottom;
|
425
|
-
var canvasXY = RG.getCanvasXY(ca);
|
426
|
-
var mouseXY = RG.getMouseXY(window.event);
|
427
|
-
|
428
|
-
var width = tooltip.offsetWidth;
|
429
|
-
var height = tooltip.offsetHeight;
|
430
|
-
|
431
|
-
// Set the top position
|
432
|
-
tooltip.style.left = 0;
|
433
|
-
tooltip.style.top = window.event.pageY - height - 5 + 'px';
|
434
|
-
|
435
|
-
// By default any overflow is hidden
|
436
|
-
tooltip.style.overflow = '';
|
437
|
-
|
438
|
-
// Reposition the tooltip if at the edges:
|
439
|
-
|
440
|
-
// LEFT edge
|
441
|
-
if (canvasXY[0] + mouseXY[0] - (width / 2) < 0) {
|
442
|
-
tooltip.style.left = canvasXY[0] + mouseXY[0] - (width * 0.1) + 'px';
|
443
|
-
|
444
|
-
// RIGHT edge
|
445
|
-
} else if (canvasXY[0] + mouseXY[0] + (width / 2) > doc.body.offsetWidth) {
|
446
|
-
tooltip.style.left = canvasXY[0] + mouseXY[0] - (width * 0.9) + 'px';
|
447
|
-
|
448
|
-
// Default positioning - CENTERED
|
449
|
-
} else {
|
450
|
-
tooltip.style.left = canvasXY[0] + mouseXY[0] - (width / 2) + 'px';
|
451
|
-
}
|
452
|
-
};
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
/**
|
458
|
-
* Each object type has its own Highlight() function which highlights the appropriate shape
|
459
|
-
*
|
460
|
-
* @param object shape The shape to highlight
|
461
|
-
*/
|
462
|
-
this.highlight =
|
463
|
-
this.Highlight = function (shape)
|
464
|
-
{
|
465
|
-
if (typeof prop['chart.highlight.style'] === 'function') {
|
466
|
-
(prop['chart.highlight.style'])(shape);
|
467
|
-
}
|
468
|
-
};
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
/**
|
474
|
-
* This allows for easy specification of gradients
|
475
|
-
*/
|
476
|
-
this.parseColors = function ()
|
477
|
-
{
|
478
|
-
|
479
|
-
// Save the original colors so that they can be restored when the canvas is reset
|
480
|
-
if (this.original_colors.length === 0) {
|
481
|
-
this.original_colors['chart.colors'] = RG.array_clone(prop['chart.colors']);
|
482
|
-
}
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
/**
|
488
|
-
* Parse various properties for colors
|
489
|
-
*/
|
490
|
-
//prop['chart.title.color'] = this.parseSingleColorForGradient(prop['chart.title.color']);
|
491
|
-
//prop['chart.text.color'] = this.parseSingleColorForGradient(prop['chart.text.color']);
|
492
|
-
prop['chart.colors'][0] = this.parseSingleColorForGradient(prop['chart.colors'][0]);
|
493
|
-
};
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
/**
|
499
|
-
* Use this function to reset the object to the post-constructor state. Eg reset colors if
|
500
|
-
* need be etc
|
501
|
-
*/
|
502
|
-
this.reset = function ()
|
503
|
-
{
|
504
|
-
};
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
/**
|
510
|
-
* This parses a single color value
|
511
|
-
*/
|
512
|
-
this.parseSingleColorForGradient = function (color)
|
513
|
-
{
|
514
|
-
if (!color) {
|
515
|
-
return color;
|
516
|
-
}
|
517
|
-
|
518
|
-
if (typeof color === 'string' && color.match(/^gradient\((.*)\)$/i)) {
|
519
|
-
|
520
|
-
var parts = RegExp.$1.split(':');
|
521
|
-
|
522
|
-
// Create the gradient
|
523
|
-
var grad = co.createLinearGradient(0,prop['chart.gutter.top'],0,ca.height - this.gutterBottom);
|
524
|
-
|
525
|
-
var diff = 1 / (parts.length - 1);
|
526
|
-
|
527
|
-
grad.addColorStop(0, RG.trim(parts[0]));
|
528
|
-
|
529
|
-
for (var j=1; j<parts.length; ++j) {
|
530
|
-
grad.addColorStop(j * diff, RG.trim(parts[j]));
|
531
|
-
}
|
532
|
-
}
|
533
|
-
|
534
|
-
return grad ? grad : color;
|
535
|
-
};
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
/**
|
541
|
-
* The function that draws the Y axis
|
542
|
-
*/
|
543
|
-
this.drawYAxis =
|
544
|
-
this.DrawYAxis = function ()
|
545
|
-
{
|
546
|
-
// Allow both axis.xxx and chart.xxx to prevent any confusion that may arise
|
547
|
-
for (i in prop) {
|
548
|
-
if (typeof i == 'string') {
|
549
|
-
var key = i.replace(/^chart\./, 'axis.');
|
550
|
-
|
551
|
-
prop[key] = prop[i];
|
552
|
-
}
|
553
|
-
}
|
554
|
-
|
555
|
-
var x = this.x,
|
556
|
-
y = this.gutterTop,
|
557
|
-
height = ca.height - this.gutterBottom - this.gutterTop,
|
558
|
-
min = +prop['chart.min'] ? +prop['chart.min'] : 0,
|
559
|
-
max = +prop['chart.max'],
|
560
|
-
title = prop['chart.title'] ? prop['chart.title'] : '',
|
561
|
-
color = prop['chart.colors'] ? prop['chart.colors'][0] : 'black',
|
562
|
-
title_color = prop['chart.title.color'] ? prop['chart.title.color'] : color,
|
563
|
-
label_color = prop['chart.text.color'] ? prop['chart.text.color'] : color,
|
564
|
-
numticks = typeof(prop['chart.numticks']) == 'number' ? prop['chart.numticks'] : 10,
|
565
|
-
labels_specific = prop['chart.labels.specific'],
|
566
|
-
numlabels = prop['chart.numlabels'] ? prop['chart.numlabels'] : 5,
|
567
|
-
font = prop['chart.text.font'] ? prop['chart.text.font'] : 'Arial',
|
568
|
-
size = prop['chart.text.size'] ? prop['chart.text.size'] : 10
|
569
|
-
align = typeof(prop['chart.align']) == 'string'? prop['chart.align'] : 'left',
|
570
|
-
formatter = prop['chart.scale.formatter'],
|
571
|
-
decimals = prop['chart.scale.decimals'],
|
572
|
-
invert = prop['chart.scale.invert'],
|
573
|
-
scale_visible = prop['chart.scale.visible'],
|
574
|
-
units_pre = prop['chart.units.pre'],
|
575
|
-
units_post = prop['chart.units.post'],
|
576
|
-
linewidth = prop['chart.linewidth'] ? prop['chart.linewidth'] : 1,
|
577
|
-
notopendtick = prop['chart.noendtick.top'],
|
578
|
-
nobottomendtick = prop['chart.noendtick.bottom'],
|
579
|
-
noyaxis = prop['chart.noyaxis'],
|
580
|
-
xaxispos = prop['chart.xaxispos']
|
581
|
-
|
582
|
-
|
583
|
-
// This fixes missing corner pixels in Chrome
|
584
|
-
co.lineWidth = linewidth + 0.001;
|
585
|
-
|
586
|
-
|
587
|
-
/**
|
588
|
-
* Set the color
|
589
|
-
*/
|
590
|
-
co.strokeStyle = color;
|
591
|
-
|
592
|
-
if (!noyaxis) {
|
593
|
-
/**
|
594
|
-
* Draw the main vertical line
|
595
|
-
*/
|
596
|
-
pa2(co,['b','m',Math.round(x), y,'l',Math.round(x), y + height,'s',color]);
|
597
|
-
|
598
|
-
/**
|
599
|
-
* Draw the axes tickmarks
|
600
|
-
*/
|
601
|
-
if (numticks) {
|
602
|
-
|
603
|
-
var gap = (xaxispos == 'center' ? height / 2 : height) / numticks;
|
604
|
-
var halfheight = height / 2;
|
605
|
-
|
606
|
-
co.beginPath();
|
607
|
-
for (var i=(notopendtick ? 1 : 0); i<=(numticks - (nobottomendtick || xaxispos == 'center'? 1 : 0)); ++i) {
|
608
|
-
pa2(co, ['m',align == 'right' ? x + 3 : x - 3, Math.round(y + (gap *i)),'l',x, Math.round(y + (gap *i))]);
|
609
|
-
}
|
610
|
-
|
611
|
-
// Draw the bottom halves ticks if the X axis is in the center
|
612
|
-
if (xaxispos == 'center') {
|
613
|
-
for (var i=1; i<=numticks; ++i) {
|
614
|
-
pa2(co, ['m',align == 'right' ? x + 3 : x - 3, Math.round(y + halfheight + (gap *i)),'l',x, Math.round(y + halfheight + (gap *i))]);
|
615
|
-
}
|
616
|
-
}
|
617
|
-
co.stroke();
|
618
|
-
}
|
619
|
-
}
|
620
|
-
|
621
|
-
|
622
|
-
/**
|
623
|
-
* Draw the scale for the axes
|
624
|
-
*/
|
625
|
-
co.fillStyle = label_color;
|
626
|
-
//co.beginPath();
|
627
|
-
var text_len = 0;
|
628
|
-
if (scale_visible) {
|
629
|
-
if (labels_specific && labels_specific.length) {
|
630
|
-
|
631
|
-
var text_len = 0;
|
632
|
-
|
633
|
-
// First - gp through the labels to find the longest
|
634
|
-
for (var i=0,len=labels_specific.length; i<len; i+=1) {
|
635
|
-
text_len = Math.max(text_len, co.measureText(labels_specific[i]).width);
|
636
|
-
}
|
637
|
-
|
638
|
-
for (var i=0,len=labels_specific.length; i<len; ++i) {
|
639
|
-
|
640
|
-
var gap = (len-1) > 0 ? (height / (len-1)) : 0;
|
641
|
-
|
642
|
-
if (xaxispos == 'center') {
|
643
|
-
gap /= 2;
|
644
|
-
}
|
645
|
-
|
646
|
-
RG.text2(this, {
|
647
|
-
'font': font,
|
648
|
-
'size': size,
|
649
|
-
'x': x - (align == 'right' ? -5 : 5),
|
650
|
-
'y': (i * gap) + this.gutterTop,
|
651
|
-
'text': labels_specific[i],
|
652
|
-
'valign': 'center',
|
653
|
-
'halign': align == 'right' ? 'left' : 'right',
|
654
|
-
'tag': 'scale'
|
655
|
-
});
|
656
|
-
|
657
|
-
/**
|
658
|
-
* Store the max length so that it can be used if necessary to determine
|
659
|
-
* whether the mouse is over the axis.
|
660
|
-
*/
|
661
|
-
this.maxLabelLength = ma.max(this.maxLabelLength, co.measureText(labels_specific[i]).width);
|
662
|
-
}
|
663
|
-
|
664
|
-
if (xaxispos == 'center') {
|
665
|
-
|
666
|
-
// It's "-2" so that the center label isn't added twice
|
667
|
-
for (var i=(labels_specific.length-2); i>=0; --i) {
|
668
|
-
|
669
|
-
RG.text2(this, {
|
670
|
-
'font':font,
|
671
|
-
'size':size,
|
672
|
-
'x':x - (align == 'right' ? -5 : 5),
|
673
|
-
'y':ca.height - this.gutterBottom - (i * gap),
|
674
|
-
'text':labels_specific[i],
|
675
|
-
'valign':'center',
|
676
|
-
'halign':align == 'right' ? 'left' : 'right',
|
677
|
-
'tag': 'scale'
|
678
|
-
});
|
679
|
-
}
|
680
|
-
}
|
681
|
-
|
682
|
-
} else {
|
683
|
-
|
684
|
-
for (var i=0; i<=numlabels; ++i) {
|
685
|
-
|
686
|
-
var original = ((max - min) * ((numlabels-i) / numlabels)) + min;
|
687
|
-
|
688
|
-
if (original == 0 && prop['chart.scale.zerostart'] == false) {
|
689
|
-
continue;
|
690
|
-
}
|
691
|
-
|
692
|
-
var text = RG.number_format(this, original.toFixed(decimals), units_pre, units_post);
|
693
|
-
var text = String(typeof(formatter) == 'function' ? formatter(this, original) : text);
|
694
|
-
|
695
|
-
// text_len is used below for positioning the title
|
696
|
-
var text_len = Math.max(text_len, co.measureText(text).width);
|
697
|
-
this.maxLabelLength = text_len;
|
698
|
-
|
699
|
-
if (invert) {
|
700
|
-
var y = height - ((height / numlabels)*i);
|
701
|
-
} else {
|
702
|
-
var y = (height / numlabels)*i;
|
703
|
-
}
|
704
|
-
|
705
|
-
if (prop['chart.xaxispos'] == 'center') {
|
706
|
-
y = y / 2;
|
707
|
-
}
|
708
|
-
|
709
|
-
// This fixes a bug, Replace this: -,400 with this: -400
|
710
|
-
text = text.replace(/^-,([0-9])/, '-$1');
|
711
|
-
|
712
|
-
|
713
|
-
/**
|
714
|
-
* Now - draw the labels
|
715
|
-
*/
|
716
|
-
RG.text2(this, {
|
717
|
-
'font':font,
|
718
|
-
'size':size,
|
719
|
-
'x':x - (align == 'right' ? -5 : 5),
|
720
|
-
'y':y + this.gutterTop,
|
721
|
-
'text':text,
|
722
|
-
'valign':'center',
|
723
|
-
'halign':align == 'right' ? 'left' : 'right',
|
724
|
-
'tag': 'scale'
|
725
|
-
});
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
/**
|
730
|
-
* Draw the bottom half of the labels if the X axis is in the center
|
731
|
-
*/
|
732
|
-
if (prop['chart.xaxispos'] == 'center' && i < numlabels) {
|
733
|
-
RG.Text2(this, {'font':font,
|
734
|
-
'size':size,
|
735
|
-
'x':x - (align == 'right' ? -5 : 5),
|
736
|
-
'y':ca.height - this.gutterBottom - y,
|
737
|
-
'text':'-' + text,
|
738
|
-
'valign':'center',
|
739
|
-
'halign':align == 'right' ? 'left' : 'right',
|
740
|
-
'tag': 'scale'
|
741
|
-
});
|
742
|
-
}
|
743
|
-
}
|
744
|
-
}
|
745
|
-
}
|
746
|
-
//co.stroke();
|
747
|
-
|
748
|
-
/**
|
749
|
-
* Draw the title for the axes
|
750
|
-
*/
|
751
|
-
if (title) {
|
752
|
-
co.beginPath();
|
753
|
-
|
754
|
-
co.fillStyle = title_color;
|
755
|
-
if (labels_specific) {
|
756
|
-
|
757
|
-
var width = 0;
|
758
|
-
for (var i=0,len=labels_specific.length; i<len; i+=1) {
|
759
|
-
width = Math.max(width, co.measureText(labels_specific[i]).width);
|
760
|
-
}
|
761
|
-
|
762
|
-
} else {
|
763
|
-
var width = co.measureText(prop['chart.units.pre'] + prop['chart.max'].toFixed(prop['chart.scale.decimals']) + prop['chart.units.post']).width;
|
764
|
-
}
|
765
|
-
|
766
|
-
|
767
|
-
RG.text2(this, {
|
768
|
-
font:font,
|
769
|
-
size:size + 2,
|
770
|
-
x:align == 'right' ? x + width + 8 : x - width - 8,
|
771
|
-
y:height / 2 + this.gutterTop,
|
772
|
-
text:title,
|
773
|
-
valign:'bottom',
|
774
|
-
halign:'center',
|
775
|
-
angle:align == 'right' ? 90 : -90,
|
776
|
-
accessible: false
|
777
|
-
});
|
778
|
-
co.stroke();
|
779
|
-
}
|
780
|
-
};
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
/**
|
786
|
-
* This detemines the maximum text width of either the scale or text
|
787
|
-
* labels - whichever is given
|
788
|
-
*
|
789
|
-
* @return number The maximum text width
|
790
|
-
*/
|
791
|
-
this.getWidth = function ()
|
792
|
-
{
|
793
|
-
var width = this.maxLabelLength;
|
794
|
-
|
795
|
-
// Add the title width if it's specified
|
796
|
-
if (prop['chart.title'] && prop['chart.title'].length) {
|
797
|
-
width += (prop['chart.text.size'] * 1.5);
|
798
|
-
}
|
799
|
-
|
800
|
-
this.width = width;
|
801
|
-
|
802
|
-
return width;
|
803
|
-
};
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
/**
|
809
|
-
* Using a function to add events makes it easier to facilitate method chaining
|
810
|
-
*
|
811
|
-
* @param string type The type of even to add
|
812
|
-
* @param function func
|
813
|
-
*/
|
814
|
-
this.on = function (type, func)
|
815
|
-
{
|
816
|
-
if (type.substr(0,2) !== 'on') {
|
817
|
-
type = 'on' + type;
|
818
|
-
}
|
819
|
-
|
820
|
-
this[type] = func;
|
821
|
-
|
822
|
-
return this;
|
823
|
-
};
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
/**
|
829
|
-
* This function runs once only
|
830
|
-
* (put at the end of the file (before any effects))
|
831
|
-
*/
|
832
|
-
this.firstDrawFunc = function ()
|
833
|
-
{
|
834
|
-
};
|
835
|
-
|
836
|
-
|
837
|
-
RG.att(ca);
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
/**
|
843
|
-
* Objects are now always registered so that the chart is redrawn if need be.
|
844
|
-
*/
|
845
|
-
RG.Register(this);
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
/**
|
851
|
-
* This is the 'end' of the constructor so if the first argument
|
852
|
-
* contains configuration data - handle that.
|
853
|
-
*/
|
854
|
-
if (parseConfObjectForOptions) {
|
855
|
-
RG.parseObjectStyleConfig(this, conf.options);
|
856
|
-
}
|
857
|
-
};
|
2
|
+
RGraph=window.RGraph||{isRGraph:true};RGraph.Drawing=RGraph.Drawing||{};RGraph.Drawing.YAxis=function(conf)
|
3
|
+
{if(typeof conf==='object'&&typeof conf.x==='number'&&typeof conf.id==='string'){var id=conf.id
|
4
|
+
var x=conf.x;var parseConfObjectForOptions=true;}else{var id=conf;var x=arguments[1];}
|
5
|
+
this.id=id;this.canvas=document.getElementById(this.id);this.context=this.canvas.getContext("2d");this.canvas.__object__=this;this.x=x;this.coords=[];this.coordsText=[];this.original_colors=[];this.maxLabelLength=0;this.firstDraw=true;this.type='drawing.yaxis';this.isRGraph=true;this.uid=RGraph.CreateUID();this.canvas.uid=this.canvas.uid?this.canvas.uid:RGraph.CreateUID();this.properties={'chart.gutter.top':25,'chart.gutter.bottom':30,'chart.min':0,'chart.max':null,'chart.colors':['black'],'chart.title':'','chart.title.color':null,'chart.numticks':5,'chart.numlabels':5,'chart.labels.specific':null,'chart.text.font':'Segoe UI, Arial, Verdana, sans-serif','chart.text.size':12,'chart.text.color':null,'chart.text.accessible':true,'chart.text.accessible.overflow':'visible','chart.text.accessible.pointerevents':true,'chart.align':'left','hart.scale.formatter':null,'chart.scale.point':'.','chart.scale.decimals':0,'chart.scale.decimals':0,'chart.scale.point':'.','chart.scale.invert':false,'chart.scale.zerostart':true,'chart.scale.visible':true,'chart.units.pre':'','chart.units.post':'','chart.linewidth':1,'chart.noendtick.top':false,'chart.noendtick.bottom':false,'chart.noyaxis':false,'chart.tooltips':null,'chart.tooltips.effect':'fade','chart.tooltips.css.class':'RGraph_tooltip','chart.tooltips.event':'onclick','chart.xaxispos':'bottom','chart.events.click':null,'chart.events.mousemove':null,'chart.clearto':'rgba(0,0,0,0)'}
|
6
|
+
if(!this.canvas){alert('[DRAWING.YAXIS] No canvas support');return;}
|
7
|
+
this.$0={};if(!this.canvas.__rgraph_aa_translated__){this.context.translate(0.5,0.5);this.canvas.__rgraph_aa_translated__=true;}
|
8
|
+
var RG=RGraph,ca=this.canvas,co=ca.getContext('2d'),prop=this.properties,pa2=RG.path2,win=window,doc=document,ma=Math
|
9
|
+
if(RG.Effects&&typeof RG.Effects.decorate==='function'){RG.Effects.decorate(this);}
|
10
|
+
this.set=this.Set=function(name)
|
11
|
+
{var value=typeof arguments[1]==='undefined'?null:arguments[1];if(arguments.length===1&&typeof name==='object'){RG.parseObjectStyleConfig(this,name);return this;}
|
12
|
+
if(name.substr(0,6)!='chart.'){name='chart.'+name;}
|
13
|
+
while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
|
14
|
+
prop[name]=value;return this;};this.get=this.Get=function(name)
|
15
|
+
{if(name.substr(0,6)!='chart.'){name='chart.'+name;}
|
16
|
+
while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
|
17
|
+
return prop[name.toLowerCase()];};this.draw=this.Draw=function()
|
18
|
+
{RG.fireCustomEvent(this,'onbeforedraw');this.gutterTop=prop['chart.gutter.top'];this.gutterBottom=prop['chart.gutter.bottom'];this.coordsText=[];if(!prop['chart.text.color'])prop['chart.text.color']=prop['chart.colors'][0];if(!prop['chart.title.color'])prop['chart.title.color']=prop['chart.colors'][0];if(!this.colorsParsed){this.parseColors();this.colorsParsed=true;}
|
19
|
+
this.drawYAxis();RG.InstallEventListeners(this);if(this.firstDraw){RG.fireCustomEvent(this,'onfirstdraw');this.firstDraw=false;this.firstDrawFunc();}
|
20
|
+
RG.FireCustomEvent(this,'ondraw');return this;};this.exec=function(func)
|
21
|
+
{func(this);return this;};this.getObjectByXY=function(e)
|
22
|
+
{if(this.getShape(e)){return this;}};this.getShape=function(e)
|
23
|
+
{var mouseXY=RG.getMouseXY(e);var mouseX=mouseXY[0];var mouseY=mouseXY[1];if(mouseX>=this.x-(prop['chart.align']=='right'?0:this.getWidth())&&mouseX<=this.x+(prop['chart.align']=='right'?this.getWidth():0)&&mouseY>=this.gutterTop&&mouseY<=(ca.height-this.gutterBottom)){var x=this.x;var y=this.gutterTop;var w=15;;var h=ca.height-this.gutterTop-this.gutterBottom;return{0:this,1:x,2:y,3:w,4:h,5:0,'object':this,'x':x,'y':y,'width':w,'height':h,'index':0,'tooltip':prop['chart.tooltips']?prop['chart.tooltips'][0]:null};}
|
24
|
+
return null;};this.highlight=this.Highlight=function(shape)
|
25
|
+
{if(typeof prop['chart.highlight.style']==='function'){(prop['chart.highlight.style'])(shape);}};this.parseColors=function()
|
26
|
+
{if(this.original_colors.length===0){this.original_colors['chart.colors']=RG.array_clone(prop['chart.colors']);}
|
27
|
+
prop['chart.colors'][0]=this.parseSingleColorForGradient(prop['chart.colors'][0]);};this.reset=function()
|
28
|
+
{};this.parseSingleColorForGradient=function(color)
|
29
|
+
{if(!color){return color;}
|
30
|
+
if(typeof color==='string'&&color.match(/^gradient\((.*)\)$/i)){var parts=RegExp.$1.split(':');var grad=co.createLinearGradient(0,prop['chart.gutter.top'],0,ca.height-this.gutterBottom);var diff=1/(parts.length-1);grad.addColorStop(0,RG.trim(parts[0]));for(var j=1;j<parts.length;++j){grad.addColorStop(j*diff,RG.trim(parts[j]));}}
|
31
|
+
return grad?grad:color;};this.drawYAxis=this.DrawYAxis=function()
|
32
|
+
{for(i in prop){if(typeof i=='string'){var key=i.replace(/^chart\./,'axis.');prop[key]=prop[i];}}
|
33
|
+
var x=this.x,y=this.gutterTop,height=ca.height-this.gutterBottom-this.gutterTop,min=+prop['chart.min']?+prop['chart.min']:0,max=+prop['chart.max'],title=prop['chart.title']?prop['chart.title']:'',color=prop['chart.colors']?prop['chart.colors'][0]:'black',title_color=prop['chart.title.color']?prop['chart.title.color']:color,label_color=prop['chart.text.color']?prop['chart.text.color']:color,numticks=typeof(prop['chart.numticks'])=='number'?prop['chart.numticks']:10,labels_specific=prop['chart.labels.specific'],numlabels=prop['chart.numlabels']?prop['chart.numlabels']:5,font=prop['chart.text.font']?prop['chart.text.font']:'Arial',size=prop['chart.text.size']?prop['chart.text.size']:10
|
34
|
+
align=typeof(prop['chart.align'])=='string'?prop['chart.align']:'left',formatter=prop['chart.scale.formatter'],decimals=prop['chart.scale.decimals'],invert=prop['chart.scale.invert'],scale_visible=prop['chart.scale.visible'],units_pre=prop['chart.units.pre'],units_post=prop['chart.units.post'],linewidth=prop['chart.linewidth']?prop['chart.linewidth']:1,notopendtick=prop['chart.noendtick.top'],nobottomendtick=prop['chart.noendtick.bottom'],noyaxis=prop['chart.noyaxis'],xaxispos=prop['chart.xaxispos']
|
35
|
+
co.lineWidth=linewidth+0.001;co.strokeStyle=color;if(!noyaxis){pa2(co,['b','m',Math.round(x),y,'l',Math.round(x),y+height,'s',color]);if(numticks){var gap=(xaxispos=='center'?height/2:height)/numticks;var halfheight=height/2;co.beginPath();for(var i=(notopendtick?1:0);i<=(numticks-(nobottomendtick||xaxispos=='center'?1:0));++i){pa2(co,['m',align=='right'?x+3:x-3,Math.round(y+(gap*i)),'l',x,Math.round(y+(gap*i))]);}
|
36
|
+
if(xaxispos=='center'){for(var i=1;i<=numticks;++i){pa2(co,['m',align=='right'?x+3:x-3,Math.round(y+halfheight+(gap*i)),'l',x,Math.round(y+halfheight+(gap*i))]);}}
|
37
|
+
co.stroke();}}
|
38
|
+
co.fillStyle=label_color;var text_len=0;if(scale_visible){if(labels_specific&&labels_specific.length){var text_len=0;for(var i=0,len=labels_specific.length;i<len;i+=1){text_len=ma.max(text_len,co.measureText(labels_specific[i]).width);}
|
39
|
+
for(var i=0,len=labels_specific.length;i<len;++i){var gap=(len-1)>0?(height/(len-1)):0;if(xaxispos=='center'){gap/=2;}
|
40
|
+
RG.text2(this,{'font':font,'size':size,'x':x-(align=='right'?-5:5),'y':(i*gap)+this.gutterTop,'text':labels_specific[i],'valign':'center','halign':align=='right'?'left':'right','tag':'scale'});this.maxLabelLength=ma.max(this.maxLabelLength,co.measureText(labels_specific[i]).width);}
|
41
|
+
if(xaxispos=='center'){for(var i=(labels_specific.length-2);i>=0;--i){RG.text2(this,{'font':font,'size':size,'x':x-(align=='right'?-5:5),'y':ca.height-this.gutterBottom-(i*gap),'text':labels_specific[i],'valign':'center','halign':align=='right'?'left':'right','tag':'scale'});}}}else{for(var i=0;i<=numlabels;++i){var original=((max-min)*((numlabels-i)/numlabels))+min;if(original==0&&prop['chart.scale.zerostart']==false){continue;}
|
42
|
+
var text=RG.numberFormat(this,original.toFixed(original===0?0:decimals),units_pre,units_post);var text=String(typeof(formatter)=='function'?formatter(this,original):text);var text_len=ma.max(text_len,co.measureText(text).width);this.maxLabelLength=text_len;if(invert){var y=height-((height/numlabels)*i);}else{var y=(height/numlabels)*i;}
|
43
|
+
if(prop['chart.xaxispos']=='center'){y=y/2;}
|
44
|
+
text=text.replace(/^-,([0-9])/,'-$1');RG.text2(this,{'font':font,'size':size,'x':x-(align=='right'?-5:5),'y':y+this.gutterTop,'text':text,'valign':'center','halign':align=='right'?'left':'right','tag':'scale'});if(prop['chart.xaxispos']=='center'&&i<numlabels){RG.Text2(this,{'font':font,'size':size,'x':x-(align=='right'?-5:5),'y':ca.height-this.gutterBottom-y,'text':'-'+text,'valign':'center','halign':align=='right'?'left':'right','tag':'scale'});}}}}
|
45
|
+
if(title){co.beginPath();co.fillStyle=title_color;if(labels_specific){var width=0;for(var i=0,len=labels_specific.length;i<len;i+=1){width=Math.max(width,co.measureText(labels_specific[i]).width);}}else{var width=co.measureText(prop['chart.units.pre']+prop['chart.max'].toFixed(prop['chart.scale.decimals'])+prop['chart.units.post']).width;}
|
46
|
+
RG.text2(this,{font:font,size:size+2,x:align=='right'?x+width+8:x-width-8,y:height/2+this.gutterTop,text:title,valign:'bottom',halign:'center',angle:align=='right'?90:-90,accessible:false});co.stroke();}};this.getWidth=function()
|
47
|
+
{var width=this.maxLabelLength;if(prop['chart.title']&&prop['chart.title'].length){width+=(prop['chart.text.size']*1.5);}
|
48
|
+
this.width=width;return width;};this.on=function(type,func)
|
49
|
+
{if(type.substr(0,2)!=='on'){type='on'+type;}
|
50
|
+
if(typeof this[type]!=='function'){this[type]=func;}else{RG.addCustomEventListener(this,type,func);}
|
51
|
+
return this;};this.firstDrawFunc=function()
|
52
|
+
{};RG.att(ca);RG.Register(this);if(parseConfObjectForOptions){RG.parseObjectStyleConfig(this,conf.options);}};
|