jquery_cheats 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +19 -2
- data/app/assets/javascripts/jqueryCheats.js +36 -1
- data/jquery_cheats.gemspec +2 -2
- data/lib/jquery_cheats.rb +4 -0
- data/vendor/assets/excanvas.js +1438 -0
- data/vendor/assets/jquery.jqplot.css +259 -0
- data/vendor/assets/jquery.jqplot.js +10901 -0
- data/vendor/assets/plugins/jqplot.BezierCurveRenderer.js +312 -0
- data/vendor/assets/plugins/jqplot.BezierCurveRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.barRenderer.js +747 -0
- data/vendor/assets/plugins/jqplot.barRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.blockRenderer.js +234 -0
- data/vendor/assets/plugins/jqplot.blockRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.bubbleRenderer.js +754 -0
- data/vendor/assets/plugins/jqplot.bubbleRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.canvasAxisLabelRenderer.js +202 -0
- data/vendor/assets/plugins/jqplot.canvasAxisLabelRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.canvasAxisTickRenderer.js +242 -0
- data/vendor/assets/plugins/jqplot.canvasAxisTickRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.canvasOverlay.js +864 -0
- data/vendor/assets/plugins/jqplot.canvasOverlay.min.js +57 -0
- data/vendor/assets/plugins/jqplot.canvasTextRenderer.js +448 -0
- data/vendor/assets/plugins/jqplot.canvasTextRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.categoryAxisRenderer.js +636 -0
- data/vendor/assets/plugins/jqplot.categoryAxisRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.ciParser.js +115 -0
- data/vendor/assets/plugins/jqplot.ciParser.min.js +57 -0
- data/vendor/assets/plugins/jqplot.cursor.js +1093 -0
- data/vendor/assets/plugins/jqplot.cursor.min.js +57 -0
- data/vendor/assets/plugins/jqplot.dateAxisRenderer.js +702 -0
- data/vendor/assets/plugins/jqplot.dateAxisRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.donutRenderer.js +800 -0
- data/vendor/assets/plugins/jqplot.donutRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.dragable.js +224 -0
- data/vendor/assets/plugins/jqplot.dragable.min.js +57 -0
- data/vendor/assets/plugins/jqplot.enhancedLegendRenderer.js +241 -0
- data/vendor/assets/plugins/jqplot.enhancedLegendRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.funnelRenderer.js +938 -0
- data/vendor/assets/plugins/jqplot.funnelRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.highlighter.js +454 -0
- data/vendor/assets/plugins/jqplot.highlighter.min.js +57 -0
- data/vendor/assets/plugins/jqplot.json2.js +475 -0
- data/vendor/assets/plugins/jqplot.json2.min.js +57 -0
- data/vendor/assets/plugins/jqplot.logAxisRenderer.js +528 -0
- data/vendor/assets/plugins/jqplot.logAxisRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.mekkoAxisRenderer.js +610 -0
- data/vendor/assets/plugins/jqplot.mekkoAxisRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.mekkoRenderer.js +436 -0
- data/vendor/assets/plugins/jqplot.mekkoRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.meterGaugeRenderer.js +1029 -0
- data/vendor/assets/plugins/jqplot.meterGaugeRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.ohlcRenderer.js +372 -0
- data/vendor/assets/plugins/jqplot.ohlcRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.pieRenderer.js +899 -0
- data/vendor/assets/plugins/jqplot.pieRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.pointLabels.js +362 -0
- data/vendor/assets/plugins/jqplot.pointLabels.min.js +57 -0
- data/vendor/assets/plugins/jqplot.pyramidAxisRenderer.js +730 -0
- data/vendor/assets/plugins/jqplot.pyramidAxisRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.pyramidGridRenderer.js +423 -0
- data/vendor/assets/plugins/jqplot.pyramidGridRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.pyramidRenderer.js +490 -0
- data/vendor/assets/plugins/jqplot.pyramidRenderer.min.js +57 -0
- data/vendor/assets/plugins/jqplot.trendline.js +222 -0
- data/vendor/assets/plugins/jqplot.trendline.min.js +57 -0
- metadata +64 -3
@@ -0,0 +1,490 @@
|
|
1
|
+
/**
|
2
|
+
* jqPlot
|
3
|
+
* Pure JavaScript plotting plugin using jQuery
|
4
|
+
*
|
5
|
+
* Version: 1.0.0b2_r1012
|
6
|
+
*
|
7
|
+
* Copyright (c) 2009-2011 Chris Leonello
|
8
|
+
* jqPlot is currently available for use in all personal or commercial projects
|
9
|
+
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
10
|
+
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
11
|
+
* choose the license that best suits your project and use it accordingly.
|
12
|
+
*
|
13
|
+
* Although not required, the author would appreciate an email letting him
|
14
|
+
* know of any substantial use of jqPlot. You can reach the author at:
|
15
|
+
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
16
|
+
*
|
17
|
+
* If you are feeling kind and generous, consider supporting the project by
|
18
|
+
* making a donation at: http://www.jqplot.com/donate.php .
|
19
|
+
*
|
20
|
+
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
21
|
+
*
|
22
|
+
* version 2007.04.27
|
23
|
+
* author Ash Searle
|
24
|
+
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
25
|
+
* http://hexmen.com/js/sprintf.js
|
26
|
+
* The author (Ash Searle) has placed this code in the public domain:
|
27
|
+
* "This code is unrestricted: you are free to use it however you like."
|
28
|
+
*
|
29
|
+
*/
|
30
|
+
(function($) {
|
31
|
+
|
32
|
+
// Need to ensure pyramid axis and grid renderers are loaded.
|
33
|
+
// You should load these with script tags in the html head, that is more efficient
|
34
|
+
// as the browser will cache the request.
|
35
|
+
// Note, have to block with synchronous request in order to execute bar renderer code.
|
36
|
+
if ($.jqplot.PyramidAxisRenderer === undefined) {
|
37
|
+
$.ajax({
|
38
|
+
url: $.jqplot.pluginLocation + 'jqplot.pyramidAxisRenderer.js',
|
39
|
+
dataType: "script",
|
40
|
+
async: false
|
41
|
+
});
|
42
|
+
}
|
43
|
+
|
44
|
+
if ($.jqplot.PyramidGridRenderer === undefined) {
|
45
|
+
$.ajax({
|
46
|
+
url: $.jqplot.pluginLocation + 'jqplot.pyramidGridRenderer.js',
|
47
|
+
dataType: "script",
|
48
|
+
async: false
|
49
|
+
});
|
50
|
+
}
|
51
|
+
|
52
|
+
$.jqplot.PyramidRenderer = function(){
|
53
|
+
$.jqplot.LineRenderer.call(this);
|
54
|
+
};
|
55
|
+
|
56
|
+
$.jqplot.PyramidRenderer.prototype = new $.jqplot.LineRenderer();
|
57
|
+
$.jqplot.PyramidRenderer.prototype.constructor = $.jqplot.PyramidRenderer;
|
58
|
+
|
59
|
+
// called with scope of a series
|
60
|
+
$.jqplot.PyramidRenderer.prototype.init = function(options, plot) {
|
61
|
+
options = options || {};
|
62
|
+
this._type = 'pyramid';
|
63
|
+
// Group: Properties
|
64
|
+
//
|
65
|
+
// prop: barPadding
|
66
|
+
this.barPadding = 10;
|
67
|
+
this.barWidth = null;
|
68
|
+
// prop: fill
|
69
|
+
// True to fill the bars.
|
70
|
+
this.fill = true;
|
71
|
+
// prop: highlightMouseOver
|
72
|
+
// True to highlight slice when moused over.
|
73
|
+
// This must be false to enable highlightMouseDown to highlight when clicking on a slice.
|
74
|
+
this.highlightMouseOver = true;
|
75
|
+
// prop: highlightMouseDown
|
76
|
+
// True to highlight when a mouse button is pressed over a slice.
|
77
|
+
// This will be disabled if highlightMouseOver is true.
|
78
|
+
this.highlightMouseDown = false;
|
79
|
+
// prop: highlightColors
|
80
|
+
// an array of colors to use when highlighting a slice.
|
81
|
+
this.highlightColors = [];
|
82
|
+
// prop: offsetBars
|
83
|
+
// False will center bars on their y value.
|
84
|
+
// True will push bars up by 1/2 bar width to fill between their y values.
|
85
|
+
// If true, there needs to be 1 more tick than there are bars.
|
86
|
+
this.offsetBars = false;
|
87
|
+
|
88
|
+
// if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
|
89
|
+
if (options.highlightMouseDown && options.highlightMouseOver == null) {
|
90
|
+
options.highlightMouseOver = false;
|
91
|
+
}
|
92
|
+
|
93
|
+
this.side = 'right';
|
94
|
+
|
95
|
+
$.extend(true, this, options);
|
96
|
+
|
97
|
+
// if (this.fill === false) {
|
98
|
+
// this.shadow = false;
|
99
|
+
// }
|
100
|
+
|
101
|
+
this.renderer.options = options;
|
102
|
+
// index of the currenty highlighted point, if any
|
103
|
+
this._highlightedPoint = null;
|
104
|
+
// Array of actual data colors used for each data point.
|
105
|
+
this._dataColors = [];
|
106
|
+
this._barPoints = [];
|
107
|
+
this.fillAxis = 'y';
|
108
|
+
this._primaryAxis = '_yaxis';
|
109
|
+
this._xnudge = 0;
|
110
|
+
|
111
|
+
// set the shape renderer options
|
112
|
+
var opts = {lineJoin:'miter', lineCap:'butt', fill:this.fill, fillRect:this.fill, isarc:false, strokeStyle:this.color, fillStyle:this.color, closePath:this.fill, lineWidth: this.lineWidth};
|
113
|
+
this.renderer.shapeRenderer.init(opts);
|
114
|
+
// set the shadow renderer options
|
115
|
+
var shadow_offset = options.shadowOffset;
|
116
|
+
// set the shadow renderer options
|
117
|
+
if (shadow_offset == null) {
|
118
|
+
// scale the shadowOffset to the width of the line.
|
119
|
+
if (this.lineWidth > 2.5) {
|
120
|
+
shadow_offset = 1.25 * (1 + (Math.atan((this.lineWidth/2.5))/0.785398163 - 1)*0.6);
|
121
|
+
// var shadow_offset = this.shadowOffset;
|
122
|
+
}
|
123
|
+
// for skinny lines, don't make such a big shadow.
|
124
|
+
else {
|
125
|
+
shadow_offset = 1.25 * Math.atan((this.lineWidth/2.5))/0.785398163;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
var sopts = {lineJoin:'miter', lineCap:'butt', fill:this.fill, fillRect:this.fill, isarc:false, angle:this.shadowAngle, offset:shadow_offset, alpha:this.shadowAlpha, depth:this.shadowDepth, closePath:this.fill, lineWidth: this.lineWidth};
|
129
|
+
this.renderer.shadowRenderer.init(sopts);
|
130
|
+
|
131
|
+
plot.postDrawHooks.addOnce(postPlotDraw);
|
132
|
+
plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
|
133
|
+
|
134
|
+
// if this is the left side of pyramid, set y values to negative.
|
135
|
+
if (this.side === 'left') {
|
136
|
+
for (var i=0, l=this.data.length; i<l; i++) {
|
137
|
+
this.data[i][1] = -Math.abs(this.data[i][1]);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
};
|
141
|
+
|
142
|
+
// setGridData
|
143
|
+
// converts the user data values to grid coordinates and stores them
|
144
|
+
// in the gridData array.
|
145
|
+
// Called with scope of a series.
|
146
|
+
$.jqplot.PyramidRenderer.prototype.setGridData = function(plot) {
|
147
|
+
// recalculate the grid data
|
148
|
+
var xp = this._xaxis.series_u2p;
|
149
|
+
var yp = this._yaxis.series_u2p;
|
150
|
+
var data = this._plotData;
|
151
|
+
var pdata = this._prevPlotData;
|
152
|
+
this.gridData = [];
|
153
|
+
this._prevGridData = [];
|
154
|
+
var l = data.length;
|
155
|
+
var adjust = false;
|
156
|
+
var i;
|
157
|
+
|
158
|
+
// if any data values are < 0, consider this a negative series
|
159
|
+
for (i = 0; i < l; i++) {
|
160
|
+
if (data[i][1] < 0) {
|
161
|
+
this.side = 'left';
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
if (this._yaxis.name === 'yMidAxis' && this.side === 'right') {
|
166
|
+
this._xnudge = this._xaxis.max/2000.0;
|
167
|
+
adjust = true;
|
168
|
+
}
|
169
|
+
|
170
|
+
for (i = 0; i < l; i++) {
|
171
|
+
// if not a line series or if no nulls in data, push the converted point onto the array.
|
172
|
+
if (data[i][0] != null && data[i][1] != null) {
|
173
|
+
this.gridData.push([xp(data[i][1]), yp(data[i][0])]);
|
174
|
+
}
|
175
|
+
// else if there is a null, preserve it.
|
176
|
+
else if (data[i][0] == null) {
|
177
|
+
this.gridData.push([xp(data[i][1]), null]);
|
178
|
+
}
|
179
|
+
else if (data[i][1] == null) {
|
180
|
+
this.gridData.push(null, [yp(data[i][0])]);
|
181
|
+
}
|
182
|
+
// finally, adjust x grid data if have to
|
183
|
+
if (data[i][1] === 0 && adjust) {
|
184
|
+
this.gridData[i][0] = xp(this._xnudge);
|
185
|
+
}
|
186
|
+
}
|
187
|
+
};
|
188
|
+
|
189
|
+
// makeGridData
|
190
|
+
// converts any arbitrary data values to grid coordinates and
|
191
|
+
// returns them. This method exists so that plugins can use a series'
|
192
|
+
// linerenderer to generate grid data points without overwriting the
|
193
|
+
// grid data associated with that series.
|
194
|
+
// Called with scope of a series.
|
195
|
+
$.jqplot.PyramidRenderer.prototype.makeGridData = function(data, plot) {
|
196
|
+
// recalculate the grid data
|
197
|
+
var xp = this._xaxis.series_u2p;
|
198
|
+
var yp = this._yaxis.series_u2p;
|
199
|
+
var gd = [];
|
200
|
+
var l = data.length;
|
201
|
+
var adjust = false;
|
202
|
+
var i;
|
203
|
+
|
204
|
+
// if any data values are < 0, consider this a negative series
|
205
|
+
for (i = 0; i < l; i++) {
|
206
|
+
if (data[i][1] < 0) {
|
207
|
+
this.side = 'left';
|
208
|
+
}
|
209
|
+
}
|
210
|
+
|
211
|
+
if (this._yaxis.name === 'yMidAxis' && this.side === 'right') {
|
212
|
+
this._xnudge = this._xaxis.max/2000.0;
|
213
|
+
adjust = true;
|
214
|
+
}
|
215
|
+
|
216
|
+
for (i = 0; i < l; i++) {
|
217
|
+
// if not a line series or if no nulls in data, push the converted point onto the array.
|
218
|
+
if (data[i][0] != null && data[i][1] != null) {
|
219
|
+
gd.push([xp(data[i][1]), yp(data[i][0])]);
|
220
|
+
}
|
221
|
+
// else if there is a null, preserve it.
|
222
|
+
else if (data[i][0] == null) {
|
223
|
+
gd.push([xp(data[i][1]), null]);
|
224
|
+
}
|
225
|
+
else if (data[i][1] == null) {
|
226
|
+
gd.push([null, yp(data[i][0])]);
|
227
|
+
}
|
228
|
+
// finally, adjust x grid data if have to
|
229
|
+
if (data[i][1] === 0 && adjust) {
|
230
|
+
gd[i][0] = xp(this._xnudge);
|
231
|
+
}
|
232
|
+
}
|
233
|
+
|
234
|
+
return gd;
|
235
|
+
};
|
236
|
+
|
237
|
+
$.jqplot.PyramidRenderer.prototype.setBarWidth = function() {
|
238
|
+
// need to know how many data values we have on the approprate axis and figure it out.
|
239
|
+
var i;
|
240
|
+
var nvals = 0;
|
241
|
+
var nseries = 0;
|
242
|
+
var paxis = this[this._primaryAxis];
|
243
|
+
var s, series, pos;
|
244
|
+
nvals = paxis.max - paxis.min;
|
245
|
+
var nticks = paxis.numberTicks;
|
246
|
+
var nbins = (nticks-1)/2;
|
247
|
+
// so, now we have total number of axis values.
|
248
|
+
var temp = (this.barPadding === 0) ? 1.0 : 0;
|
249
|
+
if (paxis.name == 'xaxis' || paxis.name == 'x2axis') {
|
250
|
+
this.barWidth = (paxis._offsets.max - paxis._offsets.min) / nvals - this.barPadding + temp;
|
251
|
+
}
|
252
|
+
else {
|
253
|
+
if (this.fill) {
|
254
|
+
this.barWidth = (paxis._offsets.min - paxis._offsets.max) / nvals - this.barPadding + temp;
|
255
|
+
}
|
256
|
+
else {
|
257
|
+
this.barWidth = (paxis._offsets.min - paxis._offsets.max) / nvals;
|
258
|
+
}
|
259
|
+
}
|
260
|
+
};
|
261
|
+
|
262
|
+
$.jqplot.PyramidRenderer.prototype.draw = function(ctx, gridData, options) {
|
263
|
+
var i;
|
264
|
+
// Ughhh, have to make a copy of options b/c it may be modified later.
|
265
|
+
var opts = $.extend({}, options);
|
266
|
+
var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
|
267
|
+
var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
|
268
|
+
var fill = (opts.fill != undefined) ? opts.fill : this.fill;
|
269
|
+
var xp = this._xaxis.series_u2p;
|
270
|
+
var yp = this._yaxis.series_u2p;
|
271
|
+
var pointx, pointy;
|
272
|
+
// clear out data colors.
|
273
|
+
this._dataColors = [];
|
274
|
+
this._barPoints = [];
|
275
|
+
|
276
|
+
if (this.renderer.options.barWidth == null) {
|
277
|
+
this.renderer.setBarWidth.call(this);
|
278
|
+
}
|
279
|
+
|
280
|
+
// var temp = this._plotSeriesInfo = this.renderer.calcSeriesNumbers.call(this);
|
281
|
+
// var nvals = temp[0];
|
282
|
+
// var nseries = temp[1];
|
283
|
+
// var pos = temp[2];
|
284
|
+
var points = [],
|
285
|
+
w,
|
286
|
+
h;
|
287
|
+
|
288
|
+
// this._barNudge = 0;
|
289
|
+
|
290
|
+
if (showLine) {
|
291
|
+
var negativeColors = new $.jqplot.ColorGenerator(this.negativeSeriesColors);
|
292
|
+
var positiveColors = new $.jqplot.ColorGenerator(this.seriesColors);
|
293
|
+
var negativeColor = negativeColors.get(this.index);
|
294
|
+
if (! this.useNegativeColors) {
|
295
|
+
negativeColor = opts.fillStyle;
|
296
|
+
}
|
297
|
+
var positiveColor = opts.fillStyle;
|
298
|
+
var base;
|
299
|
+
var xstart = this._xaxis.series_u2p(this._xnudge);
|
300
|
+
var ystart = this._yaxis.series_u2p(this._yaxis.min);
|
301
|
+
var yend = this._yaxis.series_u2p(this._yaxis.max);
|
302
|
+
var bw = this.barWidth;
|
303
|
+
var bw2 = bw/2.0;
|
304
|
+
var points = [];
|
305
|
+
var yadj = this.offsetBars ? bw2 : 0;
|
306
|
+
|
307
|
+
for (var i=0, l=gridData.length; i<l; i++) {
|
308
|
+
if (this.data[i][0] == null) {
|
309
|
+
continue;
|
310
|
+
}
|
311
|
+
base = gridData[i][1];
|
312
|
+
// not stacked and first series in stack
|
313
|
+
|
314
|
+
if (this._plotData[i][1] < 0) {
|
315
|
+
if (this.varyBarColor && !this._stack) {
|
316
|
+
if (this.useNegativeColors) {
|
317
|
+
opts.fillStyle = negativeColors.next();
|
318
|
+
}
|
319
|
+
else {
|
320
|
+
opts.fillStyle = positiveColors.next();
|
321
|
+
}
|
322
|
+
}
|
323
|
+
}
|
324
|
+
else {
|
325
|
+
if (this.varyBarColor && !this._stack) {
|
326
|
+
opts.fillStyle = positiveColors.next();
|
327
|
+
}
|
328
|
+
else {
|
329
|
+
opts.fillStyle = positiveColor;
|
330
|
+
}
|
331
|
+
}
|
332
|
+
|
333
|
+
if (this.fill) {
|
334
|
+
|
335
|
+
if (this._plotData[i][1] >= 0) {
|
336
|
+
// xstart = this._xaxis.series_u2p(this._xnudge);
|
337
|
+
w = gridData[i][0] - xstart;
|
338
|
+
h = this.barWidth;
|
339
|
+
points = [xstart, base - bw2 - yadj, w, h];
|
340
|
+
}
|
341
|
+
else {
|
342
|
+
// xstart = this._xaxis.series_u2p(0);
|
343
|
+
w = xstart - gridData[i][0];
|
344
|
+
h = this.barWidth;
|
345
|
+
points = [gridData[i][0], base - bw2 - yadj, w, h];
|
346
|
+
}
|
347
|
+
|
348
|
+
this._barPoints.push([[points[0], points[1] + h], [points[0], points[1]], [points[0] + w, points[1]], [points[0] + w, points[1] + h]]);
|
349
|
+
|
350
|
+
if (shadow) {
|
351
|
+
this.renderer.shadowRenderer.draw(ctx, points);
|
352
|
+
}
|
353
|
+
var clr = opts.fillStyle || this.color;
|
354
|
+
this._dataColors.push(clr);
|
355
|
+
this.renderer.shapeRenderer.draw(ctx, points, opts);
|
356
|
+
}
|
357
|
+
|
358
|
+
else {
|
359
|
+
if (i === 0) {
|
360
|
+
points =[[xstart, ystart], [gridData[i][0], ystart], [gridData[i][0], gridData[i][1] - bw2 - yadj]];
|
361
|
+
}
|
362
|
+
|
363
|
+
else if (i < l-1) {
|
364
|
+
points = points.concat([[gridData[i-1][0], gridData[i-1][1] - bw2 - yadj], [gridData[i][0], gridData[i][1] + bw2 - yadj], [gridData[i][0], gridData[i][1] - bw2 - yadj]]);
|
365
|
+
}
|
366
|
+
|
367
|
+
// finally, draw the line
|
368
|
+
else {
|
369
|
+
points = points.concat([[gridData[i-1][0], gridData[i-1][1] - bw2 - yadj], [gridData[i][0], gridData[i][1] + bw2 - yadj], [gridData[i][0], yend], [xstart, yend]]);
|
370
|
+
|
371
|
+
if (shadow) {
|
372
|
+
this.renderer.shadowRenderer.draw(ctx, points);
|
373
|
+
}
|
374
|
+
var clr = opts.fillStyle || this.color;
|
375
|
+
this._dataColors.push(clr);
|
376
|
+
this.renderer.shapeRenderer.draw(ctx, points, opts);
|
377
|
+
}
|
378
|
+
}
|
379
|
+
}
|
380
|
+
}
|
381
|
+
|
382
|
+
if (this.highlightColors.length == 0) {
|
383
|
+
this.highlightColors = $.jqplot.computeHighlightColors(this._dataColors);
|
384
|
+
}
|
385
|
+
|
386
|
+
else if (typeof(this.highlightColors) == 'string') {
|
387
|
+
this.highlightColors = [];
|
388
|
+
for (var i=0; i<this._dataColors.length; i++) {
|
389
|
+
this.highlightColors.push(this.highlightColors);
|
390
|
+
}
|
391
|
+
}
|
392
|
+
|
393
|
+
};
|
394
|
+
|
395
|
+
|
396
|
+
// setup default renderers for axes and legend so user doesn't have to
|
397
|
+
// called with scope of plot
|
398
|
+
function preInit(target, data, options) {
|
399
|
+
options = options || {};
|
400
|
+
options.axesDefaults = options.axesDefaults || {};
|
401
|
+
options.grid = options.grid || {};
|
402
|
+
options.legend = options.legend || {};
|
403
|
+
options.seriesDefaults = options.seriesDefaults || {};
|
404
|
+
// only set these if there is a pie series
|
405
|
+
var setopts = false;
|
406
|
+
if (options.seriesDefaults.renderer === $.jqplot.PyramidRenderer) {
|
407
|
+
setopts = true;
|
408
|
+
}
|
409
|
+
else if (options.series) {
|
410
|
+
for (var i=0; i < options.series.length; i++) {
|
411
|
+
if (options.series[i].renderer === $.jqplot.PyramidRenderer) {
|
412
|
+
setopts = true;
|
413
|
+
}
|
414
|
+
}
|
415
|
+
}
|
416
|
+
|
417
|
+
if (setopts) {
|
418
|
+
options.axesDefaults.renderer = $.jqplot.PyramidAxisRenderer;
|
419
|
+
options.grid.renderer = $.jqplot.PyramidGridRenderer;
|
420
|
+
options.seriesDefaults.pointLabels = {show: false};
|
421
|
+
}
|
422
|
+
}
|
423
|
+
|
424
|
+
// called within context of plot
|
425
|
+
// create a canvas which we can draw on.
|
426
|
+
// insert it before the eventCanvas, so eventCanvas will still capture events.
|
427
|
+
function postPlotDraw() {
|
428
|
+
// Memory Leaks patch
|
429
|
+
if (this.plugins.pyramidRenderer && this.plugins.pyramidRenderer.highlightCanvas) {
|
430
|
+
|
431
|
+
this.plugins.pyramidRenderer.highlightCanvas.resetCanvas();
|
432
|
+
this.plugins.pyramidRenderer.highlightCanvas = null;
|
433
|
+
}
|
434
|
+
|
435
|
+
this.plugins.pyramidRenderer = {highlightedSeriesIndex:null};
|
436
|
+
this.plugins.pyramidRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
|
437
|
+
|
438
|
+
this.eventCanvas._elem.before(this.plugins.pyramidRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-pyramidRenderer-highlight-canvas', this._plotDimensions, this));
|
439
|
+
this.plugins.pyramidRenderer.highlightCanvas.setContext();
|
440
|
+
this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); });
|
441
|
+
}
|
442
|
+
|
443
|
+
function highlight (plot, sidx, pidx, points) {
|
444
|
+
var s = plot.series[sidx];
|
445
|
+
var canvas = plot.plugins.pyramidRenderer.highlightCanvas;
|
446
|
+
canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height);
|
447
|
+
s._highlightedPoint = pidx;
|
448
|
+
plot.plugins.pyramidRenderer.highlightedSeriesIndex = sidx;
|
449
|
+
var opts = {fillStyle: s.highlightColors[pidx], fillRect: false};
|
450
|
+
s.renderer.shapeRenderer.draw(canvas._ctx, points, opts);
|
451
|
+
canvas = null;
|
452
|
+
}
|
453
|
+
|
454
|
+
function unhighlight (plot) {
|
455
|
+
var canvas = plot.plugins.pyramidRenderer.highlightCanvas;
|
456
|
+
canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height);
|
457
|
+
for (var i=0; i<plot.series.length; i++) {
|
458
|
+
plot.series[i]._highlightedPoint = null;
|
459
|
+
}
|
460
|
+
plot.plugins.pyramidRenderer.highlightedSeriesIndex = null;
|
461
|
+
plot.target.trigger('jqplotDataUnhighlight');
|
462
|
+
canvas = null;
|
463
|
+
}
|
464
|
+
|
465
|
+
|
466
|
+
function handleMove(ev, gridpos, datapos, neighbor, plot) {
|
467
|
+
if (neighbor) {
|
468
|
+
var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
|
469
|
+
var evt1 = jQuery.Event('jqplotDataMouseOver');
|
470
|
+
evt1.pageX = ev.pageX;
|
471
|
+
evt1.pageY = ev.pageY;
|
472
|
+
plot.target.trigger(evt1, ins);
|
473
|
+
if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.pyramidRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
|
474
|
+
var evt = jQuery.Event('jqplotDataHighlight');
|
475
|
+
evt.pageX = ev.pageX;
|
476
|
+
evt.pageY = ev.pageY;
|
477
|
+
plot.target.trigger(evt, ins);
|
478
|
+
highlight (plot, neighbor.seriesIndex, neighbor.pointIndex, neighbor.points);
|
479
|
+
}
|
480
|
+
}
|
481
|
+
else if (neighbor == null) {
|
482
|
+
unhighlight (plot);
|
483
|
+
}
|
484
|
+
}
|
485
|
+
|
486
|
+
// Have to add hook here, becuase it needs called before series is inited.
|
487
|
+
$.jqplot.preInitHooks.push(preInit);
|
488
|
+
|
489
|
+
|
490
|
+
})(jQuery);
|
@@ -0,0 +1,57 @@
|
|
1
|
+
/**
|
2
|
+
* jqPlot
|
3
|
+
* Pure JavaScript plotting plugin using jQuery
|
4
|
+
*
|
5
|
+
* Version: 1.0.0b2_r1012
|
6
|
+
*
|
7
|
+
* Copyright (c) 2009-2011 Chris Leonello
|
8
|
+
* jqPlot is currently available for use in all personal or commercial projects
|
9
|
+
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
10
|
+
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
11
|
+
* choose the license that best suits your project and use it accordingly.
|
12
|
+
*
|
13
|
+
* Although not required, the author would appreciate an email letting him
|
14
|
+
* know of any substantial use of jqPlot. You can reach the author at:
|
15
|
+
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
16
|
+
*
|
17
|
+
* If you are feeling kind and generous, consider supporting the project by
|
18
|
+
* making a donation at: http://www.jqplot.com/donate.php .
|
19
|
+
*
|
20
|
+
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
21
|
+
*
|
22
|
+
* version 2007.04.27
|
23
|
+
* author Ash Searle
|
24
|
+
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
25
|
+
* http://hexmen.com/js/sprintf.js
|
26
|
+
* The author (Ash Searle) has placed this code in the public domain:
|
27
|
+
* "This code is unrestricted: you are free to use it however you like."
|
28
|
+
*
|
29
|
+
* included jsDate library by Chris Leonello:
|
30
|
+
*
|
31
|
+
* Copyright (c) 2010-2011 Chris Leonello
|
32
|
+
*
|
33
|
+
* jsDate is currently available for use in all personal or commercial projects
|
34
|
+
* under both the MIT and GPL version 2.0 licenses. This means that you can
|
35
|
+
* choose the license that best suits your project and use it accordingly.
|
36
|
+
*
|
37
|
+
* jsDate borrows many concepts and ideas from the Date Instance
|
38
|
+
* Methods by Ken Snyder along with some parts of Ken's actual code.
|
39
|
+
*
|
40
|
+
* Ken's origianl Date Instance Methods and copyright notice:
|
41
|
+
*
|
42
|
+
* Ken Snyder (ken d snyder at gmail dot com)
|
43
|
+
* 2008-09-10
|
44
|
+
* version 2.0.2 (http://kendsnyder.com/sandbox/date/)
|
45
|
+
* Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
|
46
|
+
*
|
47
|
+
* jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
|
48
|
+
* Larry has generously given permission to adapt his code for inclusion
|
49
|
+
* into jqPlot.
|
50
|
+
*
|
51
|
+
* Larry's original code can be found here:
|
52
|
+
*
|
53
|
+
* https://github.com/lsiden/export-jqplot-to-png
|
54
|
+
*
|
55
|
+
*
|
56
|
+
*/
|
57
|
+
(function(c){if(c.jqplot.PyramidAxisRenderer===undefined){c.ajax({url:c.jqplot.pluginLocation+"jqplot.pyramidAxisRenderer.js",dataType:"script",async:false})}if(c.jqplot.PyramidGridRenderer===undefined){c.ajax({url:c.jqplot.pluginLocation+"jqplot.pyramidGridRenderer.js",dataType:"script",async:false})}c.jqplot.PyramidRenderer=function(){c.jqplot.LineRenderer.call(this)};c.jqplot.PyramidRenderer.prototype=new c.jqplot.LineRenderer();c.jqplot.PyramidRenderer.prototype.constructor=c.jqplot.PyramidRenderer;c.jqplot.PyramidRenderer.prototype.init=function(j,o){j=j||{};this._type="pyramid";this.barPadding=10;this.barWidth=null;this.fill=true;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.offsetBars=false;if(j.highlightMouseDown&&j.highlightMouseOver==null){j.highlightMouseOver=false}this.side="right";c.extend(true,this,j);this.renderer.options=j;this._highlightedPoint=null;this._dataColors=[];this._barPoints=[];this.fillAxis="y";this._primaryAxis="_yaxis";this._xnudge=0;var n={lineJoin:"miter",lineCap:"butt",fill:this.fill,fillRect:this.fill,isarc:false,strokeStyle:this.color,fillStyle:this.color,closePath:this.fill,lineWidth:this.lineWidth};this.renderer.shapeRenderer.init(n);var m=j.shadowOffset;if(m==null){if(this.lineWidth>2.5){m=1.25*(1+(Math.atan((this.lineWidth/2.5))/0.785398163-1)*0.6)}else{m=1.25*Math.atan((this.lineWidth/2.5))/0.785398163}}var h={lineJoin:"miter",lineCap:"butt",fill:this.fill,fillRect:this.fill,isarc:false,angle:this.shadowAngle,offset:m,alpha:this.shadowAlpha,depth:this.shadowDepth,closePath:this.fill,lineWidth:this.lineWidth};this.renderer.shadowRenderer.init(h);o.postDrawHooks.addOnce(f);o.eventListenerHooks.addOnce("jqplotMouseMove",e);if(this.side==="left"){for(var k=0,g=this.data.length;k<g;k++){this.data[k][1]=-Math.abs(this.data[k][1])}}};c.jqplot.PyramidRenderer.prototype.setGridData=function(p){var j=this._xaxis.series_u2p;var o=this._yaxis.series_u2p;var k=this._plotData;var n=this._prevPlotData;this.gridData=[];this._prevGridData=[];var g=k.length;var m=false;var h;for(h=0;h<g;h++){if(k[h][1]<0){this.side="left"}}if(this._yaxis.name==="yMidAxis"&&this.side==="right"){this._xnudge=this._xaxis.max/2000;m=true}for(h=0;h<g;h++){if(k[h][0]!=null&&k[h][1]!=null){this.gridData.push([j(k[h][1]),o(k[h][0])])}else{if(k[h][0]==null){this.gridData.push([j(k[h][1]),null])}else{if(k[h][1]==null){this.gridData.push(null,[o(k[h][0])])}}}if(k[h][1]===0&&m){this.gridData[h][0]=j(this._xnudge)}}};c.jqplot.PyramidRenderer.prototype.makeGridData=function(m,p){var k=this._xaxis.series_u2p;var o=this._yaxis.series_u2p;var j=[];var g=m.length;var n=false;var h;for(h=0;h<g;h++){if(m[h][1]<0){this.side="left"}}if(this._yaxis.name==="yMidAxis"&&this.side==="right"){this._xnudge=this._xaxis.max/2000;n=true}for(h=0;h<g;h++){if(m[h][0]!=null&&m[h][1]!=null){j.push([k(m[h][1]),o(m[h][0])])}else{if(m[h][0]==null){j.push([k(m[h][1]),null])}else{if(m[h][1]==null){j.push([null,o(m[h][0])])}}}if(m[h][1]===0&&n){j[h][0]=k(this._xnudge)}}return j};c.jqplot.PyramidRenderer.prototype.setBarWidth=function(){var k;var g=0;var h=0;var m=this[this._primaryAxis];var q,l,o;g=m.max-m.min;var n=m.numberTicks;var j=(n-1)/2;var p=(this.barPadding===0)?1:0;if(m.name=="xaxis"||m.name=="x2axis"){this.barWidth=(m._offsets.max-m._offsets.min)/g-this.barPadding+p}else{if(this.fill){this.barWidth=(m._offsets.min-m._offsets.max)/g-this.barPadding+p}else{this.barWidth=(m._offsets.min-m._offsets.max)/g}}};c.jqplot.PyramidRenderer.prototype.draw=function(B,I,k){var E;var u=c.extend({},k);var p=(u.shadow!=undefined)?u.shadow:this.shadow;var K=(u.showLine!=undefined)?u.showLine:this.showLine;var C=(u.fill!=undefined)?u.fill:this.fill;var t=this._xaxis.series_u2p;var G=this._yaxis.series_u2p;var z,x;this._dataColors=[];this._barPoints=[];if(this.renderer.options.barWidth==null){this.renderer.setBarWidth.call(this)}var D=[],s,F;if(K){var q=new c.jqplot.ColorGenerator(this.negativeSeriesColors);var v=new c.jqplot.ColorGenerator(this.seriesColors);var J=q.get(this.index);if(!this.useNegativeColors){J=u.fillStyle}var o=u.fillStyle;var n;var L=this._xaxis.series_u2p(this._xnudge);var j=this._yaxis.series_u2p(this._yaxis.min);var m=this._yaxis.series_u2p(this._yaxis.max);var H=this.barWidth;var y=H/2;var D=[];var r=this.offsetBars?y:0;for(var E=0,A=I.length;E<A;E++){if(this.data[E][0]==null){continue}n=I[E][1];if(this._plotData[E][1]<0){if(this.varyBarColor&&!this._stack){if(this.useNegativeColors){u.fillStyle=q.next()}else{u.fillStyle=v.next()}}}else{if(this.varyBarColor&&!this._stack){u.fillStyle=v.next()}else{u.fillStyle=o}}if(this.fill){if(this._plotData[E][1]>=0){s=I[E][0]-L;F=this.barWidth;D=[L,n-y-r,s,F]}else{s=L-I[E][0];F=this.barWidth;D=[I[E][0],n-y-r,s,F]}this._barPoints.push([[D[0],D[1]+F],[D[0],D[1]],[D[0]+s,D[1]],[D[0]+s,D[1]+F]]);if(p){this.renderer.shadowRenderer.draw(B,D)}var g=u.fillStyle||this.color;this._dataColors.push(g);this.renderer.shapeRenderer.draw(B,D,u)}else{if(E===0){D=[[L,j],[I[E][0],j],[I[E][0],I[E][1]-y-r]]}else{if(E<A-1){D=D.concat([[I[E-1][0],I[E-1][1]-y-r],[I[E][0],I[E][1]+y-r],[I[E][0],I[E][1]-y-r]])}else{D=D.concat([[I[E-1][0],I[E-1][1]-y-r],[I[E][0],I[E][1]+y-r],[I[E][0],m],[L,m]]);if(p){this.renderer.shadowRenderer.draw(B,D)}var g=u.fillStyle||this.color;this._dataColors.push(g);this.renderer.shapeRenderer.draw(B,D,u)}}}}}if(this.highlightColors.length==0){this.highlightColors=c.jqplot.computeHighlightColors(this._dataColors)}else{if(typeof(this.highlightColors)=="string"){this.highlightColors=[];for(var E=0;E<this._dataColors.length;E++){this.highlightColors.push(this.highlightColors)}}}};function b(l,k,h){h=h||{};h.axesDefaults=h.axesDefaults||{};h.grid=h.grid||{};h.legend=h.legend||{};h.seriesDefaults=h.seriesDefaults||{};var g=false;if(h.seriesDefaults.renderer===c.jqplot.PyramidRenderer){g=true}else{if(h.series){for(var j=0;j<h.series.length;j++){if(h.series[j].renderer===c.jqplot.PyramidRenderer){g=true}}}}if(g){h.axesDefaults.renderer=c.jqplot.PyramidAxisRenderer;h.grid.renderer=c.jqplot.PyramidGridRenderer;h.seriesDefaults.pointLabels={show:false}}}function f(){if(this.plugins.pyramidRenderer&&this.plugins.pyramidRenderer.highlightCanvas){this.plugins.pyramidRenderer.highlightCanvas.resetCanvas();this.plugins.pyramidRenderer.highlightCanvas=null}this.plugins.pyramidRenderer={highlightedSeriesIndex:null};this.plugins.pyramidRenderer.highlightCanvas=new c.jqplot.GenericCanvas();this.eventCanvas._elem.before(this.plugins.pyramidRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-pyramidRenderer-highlight-canvas",this._plotDimensions,this));this.plugins.pyramidRenderer.highlightCanvas.setContext();this.eventCanvas._elem.bind("mouseleave",{plot:this},function(g){d(g.data.plot)})}function a(m,l,j,i){var h=m.series[l];var g=m.plugins.pyramidRenderer.highlightCanvas;g._ctx.clearRect(0,0,g._ctx.canvas.width,g._ctx.canvas.height);h._highlightedPoint=j;m.plugins.pyramidRenderer.highlightedSeriesIndex=l;var k={fillStyle:h.highlightColors[j],fillRect:false};h.renderer.shapeRenderer.draw(g._ctx,i,k);g=null}function d(j){var g=j.plugins.pyramidRenderer.highlightCanvas;g._ctx.clearRect(0,0,g._ctx.canvas.width,g._ctx.canvas.height);for(var h=0;h<j.series.length;h++){j.series[h]._highlightedPoint=null}j.plugins.pyramidRenderer.highlightedSeriesIndex=null;j.target.trigger("jqplotDataUnhighlight");g=null}function e(k,j,n,m,l){if(m){var i=[m.seriesIndex,m.pointIndex,m.data];var h=jQuery.Event("jqplotDataMouseOver");h.pageX=k.pageX;h.pageY=k.pageY;l.target.trigger(h,i);if(l.series[i[0]].highlightMouseOver&&!(i[0]==l.plugins.pyramidRenderer.highlightedSeriesIndex&&i[1]==l.series[i[0]]._highlightedPoint)){var g=jQuery.Event("jqplotDataHighlight");g.pageX=k.pageX;g.pageY=k.pageY;l.target.trigger(g,i);a(l,m.seriesIndex,m.pointIndex,m.points)}}else{if(m==null){d(l)}}}c.jqplot.preInitHooks.push(b)})(jQuery);
|