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,436 @@
|
|
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
|
+
* Class: $.jqplot.MekkoRenderer
|
33
|
+
* Draws a Mekko style chart which shows 3 dimensional data on a 2 dimensional graph.
|
34
|
+
* the <$.jqplot.MekkoAxisRenderer> should be used with mekko charts. The mekko renderer
|
35
|
+
* overrides the default legend renderer with it's own $.jqplot.MekkoLegendRenderer
|
36
|
+
* which allows more flexibility to specify number of rows and columns in the legend.
|
37
|
+
*
|
38
|
+
* Data is specified per bar in the chart. You can specify data as an array of y values, or as
|
39
|
+
* an array of [label, value] pairs. Note that labels are used only on the first series.
|
40
|
+
* Labels on subsequent series are ignored:
|
41
|
+
*
|
42
|
+
* > bar1 = [['shirts', 8],['hats', 14],['shoes', 6],['gloves', 16],['dolls', 12]];
|
43
|
+
* > bar2 = [15,6,9,13,6];
|
44
|
+
* > bar3 = [['grumpy',4],['sneezy',2],['happy',7],['sleepy',9],['doc',7]];
|
45
|
+
*
|
46
|
+
* If you want to place labels for each bar under the axis, you use the barLabels option on
|
47
|
+
* the axes. The bar labels can be styled with the ".jqplot-mekko-barLabel" css class.
|
48
|
+
*
|
49
|
+
* > barLabels = ['Mickey Mouse', 'Donald Duck', 'Goofy'];
|
50
|
+
* > axes:{xaxis:{barLabels:barLabels}}
|
51
|
+
*
|
52
|
+
*/
|
53
|
+
|
54
|
+
|
55
|
+
$.jqplot.MekkoRenderer = function(){
|
56
|
+
this.shapeRenderer = new $.jqplot.ShapeRenderer();
|
57
|
+
// prop: borderColor
|
58
|
+
// color of the borders between areas on the chart
|
59
|
+
this.borderColor = null;
|
60
|
+
// prop: showBorders
|
61
|
+
// True to draw borders lines between areas on the chart.
|
62
|
+
// False will draw borders lines with the same color as the area.
|
63
|
+
this.showBorders = true;
|
64
|
+
};
|
65
|
+
|
66
|
+
// called with scope of series.
|
67
|
+
$.jqplot.MekkoRenderer.prototype.init = function(options, plot) {
|
68
|
+
this.fill = false;
|
69
|
+
this.fillRect = true;
|
70
|
+
this.strokeRect = true;
|
71
|
+
this.shadow = false;
|
72
|
+
// width of bar on x axis.
|
73
|
+
this._xwidth = 0;
|
74
|
+
this._xstart = 0;
|
75
|
+
$.extend(true, this.renderer, options);
|
76
|
+
// set the shape renderer options
|
77
|
+
var opts = {lineJoin:'miter', lineCap:'butt', isarc:false, fillRect:this.fillRect, strokeRect:this.strokeRect};
|
78
|
+
this.renderer.shapeRenderer.init(opts);
|
79
|
+
plot.axes.x2axis._series.push(this);
|
80
|
+
this._type = 'mekko';
|
81
|
+
};
|
82
|
+
|
83
|
+
// Method: setGridData
|
84
|
+
// converts the user data values to grid coordinates and stores them
|
85
|
+
// in the gridData array. Will convert user data into appropriate
|
86
|
+
// rectangles.
|
87
|
+
// Called with scope of a series.
|
88
|
+
$.jqplot.MekkoRenderer.prototype.setGridData = function(plot) {
|
89
|
+
// recalculate the grid data
|
90
|
+
var xp = this._xaxis.series_u2p;
|
91
|
+
var yp = this._yaxis.series_u2p;
|
92
|
+
var data = this._plotData;
|
93
|
+
this.gridData = [];
|
94
|
+
// figure out width on x axis.
|
95
|
+
// this._xwidth = this._sumy / plot._sumy * this.canvas.getWidth();
|
96
|
+
this._xwidth = xp(this._sumy) - xp(0);
|
97
|
+
if (this.index>0) {
|
98
|
+
this._xstart = plot.series[this.index-1]._xstart + plot.series[this.index-1]._xwidth;
|
99
|
+
}
|
100
|
+
var totheight = this.canvas.getHeight();
|
101
|
+
var sumy = 0;
|
102
|
+
var cury;
|
103
|
+
var curheight;
|
104
|
+
for (var i=0; i<data.length; i++) {
|
105
|
+
if (data[i] != null) {
|
106
|
+
sumy += data[i][1];
|
107
|
+
cury = totheight - (sumy / this._sumy * totheight);
|
108
|
+
curheight = data[i][1] / this._sumy * totheight;
|
109
|
+
this.gridData.push([this._xstart, cury, this._xwidth, curheight]);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
};
|
113
|
+
|
114
|
+
// Method: makeGridData
|
115
|
+
// converts any arbitrary data values to grid coordinates and
|
116
|
+
// returns them. This method exists so that plugins can use a series'
|
117
|
+
// linerenderer to generate grid data points without overwriting the
|
118
|
+
// grid data associated with that series.
|
119
|
+
// Called with scope of a series.
|
120
|
+
$.jqplot.MekkoRenderer.prototype.makeGridData = function(data, plot) {
|
121
|
+
// recalculate the grid data
|
122
|
+
// figure out width on x axis.
|
123
|
+
var xp = this._xaxis.series_u2p;
|
124
|
+
var totheight = this.canvas.getHeight();
|
125
|
+
var sumy = 0;
|
126
|
+
var cury;
|
127
|
+
var curheight;
|
128
|
+
var gd = [];
|
129
|
+
for (var i=0; i<data.length; i++) {
|
130
|
+
if (data[i] != null) {
|
131
|
+
sumy += data[i][1];
|
132
|
+
cury = totheight - (sumy / this._sumy * totheight);
|
133
|
+
curheight = data[i][1] / this._sumy * totheight;
|
134
|
+
gd.push([this._xstart, cury, this._xwidth, curheight]);
|
135
|
+
}
|
136
|
+
}
|
137
|
+
return gd;
|
138
|
+
};
|
139
|
+
|
140
|
+
|
141
|
+
// called within scope of series.
|
142
|
+
$.jqplot.MekkoRenderer.prototype.draw = function(ctx, gd, options) {
|
143
|
+
var i;
|
144
|
+
var opts = (options != undefined) ? options : {};
|
145
|
+
var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
|
146
|
+
var colorGenerator = new $.jqplot.ColorGenerator(this.seriesColors);
|
147
|
+
ctx.save();
|
148
|
+
if (gd.length) {
|
149
|
+
if (showLine) {
|
150
|
+
for (i=0; i<gd.length; i++){
|
151
|
+
opts.fillStyle = colorGenerator.next();
|
152
|
+
if (this.renderer.showBorders) {
|
153
|
+
opts.strokeStyle = this.renderer.borderColor;
|
154
|
+
}
|
155
|
+
else {
|
156
|
+
opts.strokeStyle = opts.fillStyle;
|
157
|
+
}
|
158
|
+
this.renderer.shapeRenderer.draw(ctx, gd[i], opts);
|
159
|
+
}
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
ctx.restore();
|
164
|
+
};
|
165
|
+
|
166
|
+
$.jqplot.MekkoRenderer.prototype.drawShadow = function(ctx, gd, options) {
|
167
|
+
// This is a no-op, no shadows on mekko charts.
|
168
|
+
};
|
169
|
+
|
170
|
+
/**
|
171
|
+
* Class: $.jqplot.MekkoLegendRenderer
|
172
|
+
* Legend renderer used by mekko charts with options for
|
173
|
+
* controlling number or rows and columns as well as placement
|
174
|
+
* outside of plot area.
|
175
|
+
*
|
176
|
+
*/
|
177
|
+
$.jqplot.MekkoLegendRenderer = function(){
|
178
|
+
//
|
179
|
+
};
|
180
|
+
|
181
|
+
$.jqplot.MekkoLegendRenderer.prototype.init = function(options) {
|
182
|
+
// prop: numberRows
|
183
|
+
// Maximum number of rows in the legend. 0 or null for unlimited.
|
184
|
+
this.numberRows = null;
|
185
|
+
// prop: numberColumns
|
186
|
+
// Maximum number of columns in the legend. 0 or null for unlimited.
|
187
|
+
this.numberColumns = null;
|
188
|
+
// this will override the placement option on the Legend object
|
189
|
+
this.placement = "outside";
|
190
|
+
$.extend(true, this, options);
|
191
|
+
};
|
192
|
+
|
193
|
+
// called with scope of legend
|
194
|
+
$.jqplot.MekkoLegendRenderer.prototype.draw = function() {
|
195
|
+
var legend = this;
|
196
|
+
if (this.show) {
|
197
|
+
var series = this._series;
|
198
|
+
var ss = 'position:absolute;';
|
199
|
+
ss += (this.background) ? 'background:'+this.background+';' : '';
|
200
|
+
ss += (this.border) ? 'border:'+this.border+';' : '';
|
201
|
+
ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : '';
|
202
|
+
ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : '';
|
203
|
+
ss += (this.textColor) ? 'color:'+this.textColor+';' : '';
|
204
|
+
this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>');
|
205
|
+
// Mekko charts legends don't go by number of series, but by number of data points
|
206
|
+
// in the series. Refactor things here for that.
|
207
|
+
|
208
|
+
var pad = false,
|
209
|
+
reverse = true, // mekko charts are always stacked, so reverse
|
210
|
+
nr, nc;
|
211
|
+
var s = series[0];
|
212
|
+
var colorGenerator = new $.jqplot.ColorGenerator(s.seriesColors);
|
213
|
+
|
214
|
+
if (s.show) {
|
215
|
+
var pd = s.data;
|
216
|
+
if (this.numberRows) {
|
217
|
+
nr = this.numberRows;
|
218
|
+
if (!this.numberColumns){
|
219
|
+
nc = Math.ceil(pd.length/nr);
|
220
|
+
}
|
221
|
+
else{
|
222
|
+
nc = this.numberColumns;
|
223
|
+
}
|
224
|
+
}
|
225
|
+
else if (this.numberColumns) {
|
226
|
+
nc = this.numberColumns;
|
227
|
+
nr = Math.ceil(pd.length/this.numberColumns);
|
228
|
+
}
|
229
|
+
else {
|
230
|
+
nr = pd.length;
|
231
|
+
nc = 1;
|
232
|
+
}
|
233
|
+
|
234
|
+
var i, j, tr, td1, td2, lt, rs, color;
|
235
|
+
var idx = 0;
|
236
|
+
|
237
|
+
for (i=0; i<nr; i++) {
|
238
|
+
if (reverse){
|
239
|
+
tr = $('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem);
|
240
|
+
}
|
241
|
+
else{
|
242
|
+
tr = $('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem);
|
243
|
+
}
|
244
|
+
for (j=0; j<nc; j++) {
|
245
|
+
if (idx < pd.length) {
|
246
|
+
lt = this.labels[idx] || pd[idx][0].toString();
|
247
|
+
color = colorGenerator.next();
|
248
|
+
if (!reverse){
|
249
|
+
if (i>0){
|
250
|
+
pad = true;
|
251
|
+
}
|
252
|
+
else{
|
253
|
+
pad = false;
|
254
|
+
}
|
255
|
+
}
|
256
|
+
else{
|
257
|
+
if (i == nr -1){
|
258
|
+
pad = false;
|
259
|
+
}
|
260
|
+
else{
|
261
|
+
pad = true;
|
262
|
+
}
|
263
|
+
}
|
264
|
+
rs = (pad) ? this.rowSpacing : '0';
|
265
|
+
|
266
|
+
td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+
|
267
|
+
'<div><div class="jqplot-table-legend-swatch" style="border-color:'+color+';"></div>'+
|
268
|
+
'</div></td>');
|
269
|
+
td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>');
|
270
|
+
if (this.escapeHtml){
|
271
|
+
td2.text(lt);
|
272
|
+
}
|
273
|
+
else {
|
274
|
+
td2.html(lt);
|
275
|
+
}
|
276
|
+
if (reverse) {
|
277
|
+
td2.prependTo(tr);
|
278
|
+
td1.prependTo(tr);
|
279
|
+
}
|
280
|
+
else {
|
281
|
+
td1.appendTo(tr);
|
282
|
+
td2.appendTo(tr);
|
283
|
+
}
|
284
|
+
pad = true;
|
285
|
+
}
|
286
|
+
idx++;
|
287
|
+
}
|
288
|
+
}
|
289
|
+
|
290
|
+
tr = null;
|
291
|
+
td1 = null;
|
292
|
+
td2 = null;
|
293
|
+
}
|
294
|
+
}
|
295
|
+
return this._elem;
|
296
|
+
};
|
297
|
+
|
298
|
+
$.jqplot.MekkoLegendRenderer.prototype.pack = function(offsets) {
|
299
|
+
if (this.show) {
|
300
|
+
// fake a grid for positioning
|
301
|
+
var grid = {_top:offsets.top, _left:offsets.left, _right:offsets.right, _bottom:this._plotDimensions.height - offsets.bottom};
|
302
|
+
if (this.placement == 'insideGrid') {
|
303
|
+
switch (this.location) {
|
304
|
+
case 'nw':
|
305
|
+
var a = grid._left + this.xoffset;
|
306
|
+
var b = grid._top + this.yoffset;
|
307
|
+
this._elem.css('left', a);
|
308
|
+
this._elem.css('top', b);
|
309
|
+
break;
|
310
|
+
case 'n':
|
311
|
+
var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
|
312
|
+
var b = grid._top + this.yoffset;
|
313
|
+
this._elem.css('left', a);
|
314
|
+
this._elem.css('top', b);
|
315
|
+
break;
|
316
|
+
case 'ne':
|
317
|
+
var a = offsets.right + this.xoffset;
|
318
|
+
var b = grid._top + this.yoffset;
|
319
|
+
this._elem.css({right:a, top:b});
|
320
|
+
break;
|
321
|
+
case 'e':
|
322
|
+
var a = offsets.right + this.xoffset;
|
323
|
+
var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
|
324
|
+
this._elem.css({right:a, top:b});
|
325
|
+
break;
|
326
|
+
case 'se':
|
327
|
+
var a = offsets.right + this.xoffset;
|
328
|
+
var b = offsets.bottom + this.yoffset;
|
329
|
+
this._elem.css({right:a, bottom:b});
|
330
|
+
break;
|
331
|
+
case 's':
|
332
|
+
var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
|
333
|
+
var b = offsets.bottom + this.yoffset;
|
334
|
+
this._elem.css({left:a, bottom:b});
|
335
|
+
break;
|
336
|
+
case 'sw':
|
337
|
+
var a = grid._left + this.xoffset;
|
338
|
+
var b = offsets.bottom + this.yoffset;
|
339
|
+
this._elem.css({left:a, bottom:b});
|
340
|
+
break;
|
341
|
+
case 'w':
|
342
|
+
var a = grid._left + this.xoffset;
|
343
|
+
var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
|
344
|
+
this._elem.css({left:a, top:b});
|
345
|
+
break;
|
346
|
+
default: // same as 'se'
|
347
|
+
var a = grid._right - this.xoffset;
|
348
|
+
var b = grid._bottom + this.yoffset;
|
349
|
+
this._elem.css({right:a, bottom:b});
|
350
|
+
break;
|
351
|
+
}
|
352
|
+
|
353
|
+
}
|
354
|
+
else {
|
355
|
+
switch (this.location) {
|
356
|
+
case 'nw':
|
357
|
+
var a = this._plotDimensions.width - grid._left + this.xoffset;
|
358
|
+
var b = grid._top + this.yoffset;
|
359
|
+
this._elem.css('right', a);
|
360
|
+
this._elem.css('top', b);
|
361
|
+
break;
|
362
|
+
case 'n':
|
363
|
+
var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
|
364
|
+
var b = this._plotDimensions.height - grid._top + this.yoffset;
|
365
|
+
this._elem.css('left', a);
|
366
|
+
this._elem.css('bottom', b);
|
367
|
+
break;
|
368
|
+
case 'ne':
|
369
|
+
var a = this._plotDimensions.width - offsets.right + this.xoffset;
|
370
|
+
var b = grid._top + this.yoffset;
|
371
|
+
this._elem.css({left:a, top:b});
|
372
|
+
break;
|
373
|
+
case 'e':
|
374
|
+
var a = this._plotDimensions.width - offsets.right + this.xoffset;
|
375
|
+
var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
|
376
|
+
this._elem.css({left:a, top:b});
|
377
|
+
break;
|
378
|
+
case 'se':
|
379
|
+
var a = this._plotDimensions.width - offsets.right + this.xoffset;
|
380
|
+
var b = offsets.bottom + this.yoffset;
|
381
|
+
this._elem.css({left:a, bottom:b});
|
382
|
+
break;
|
383
|
+
case 's':
|
384
|
+
var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
|
385
|
+
var b = this._plotDimensions.height - offsets.bottom + this.yoffset;
|
386
|
+
this._elem.css({left:a, top:b});
|
387
|
+
break;
|
388
|
+
case 'sw':
|
389
|
+
var a = this._plotDimensions.width - grid._left + this.xoffset;
|
390
|
+
var b = offsets.bottom + this.yoffset;
|
391
|
+
this._elem.css({right:a, bottom:b});
|
392
|
+
break;
|
393
|
+
case 'w':
|
394
|
+
var a = this._plotDimensions.width - grid._left + this.xoffset;
|
395
|
+
var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
|
396
|
+
this._elem.css({right:a, top:b});
|
397
|
+
break;
|
398
|
+
default: // same as 'se'
|
399
|
+
var a = grid._right - this.xoffset;
|
400
|
+
var b = grid._bottom + this.yoffset;
|
401
|
+
this._elem.css({right:a, bottom:b});
|
402
|
+
break;
|
403
|
+
}
|
404
|
+
}
|
405
|
+
}
|
406
|
+
};
|
407
|
+
|
408
|
+
// setup default renderers for axes and legend so user doesn't have to
|
409
|
+
// called with scope of plot
|
410
|
+
function preInit(target, data, options) {
|
411
|
+
options = options || {};
|
412
|
+
options.axesDefaults = options.axesDefaults || {};
|
413
|
+
options.legend = options.legend || {};
|
414
|
+
options.seriesDefaults = options.seriesDefaults || {};
|
415
|
+
var setopts = false;
|
416
|
+
if (options.seriesDefaults.renderer == $.jqplot.MekkoRenderer) {
|
417
|
+
setopts = true;
|
418
|
+
}
|
419
|
+
else if (options.series) {
|
420
|
+
for (var i=0; i < options.series.length; i++) {
|
421
|
+
if (options.series[i].renderer == $.jqplot.MekkoRenderer) {
|
422
|
+
setopts = true;
|
423
|
+
}
|
424
|
+
}
|
425
|
+
}
|
426
|
+
|
427
|
+
if (setopts) {
|
428
|
+
options.axesDefaults.renderer = $.jqplot.MekkoAxisRenderer;
|
429
|
+
options.legend.renderer = $.jqplot.MekkoLegendRenderer;
|
430
|
+
options.legend.preDraw = true;
|
431
|
+
}
|
432
|
+
}
|
433
|
+
|
434
|
+
$.jqplot.preInitHooks.push(preInit);
|
435
|
+
|
436
|
+
})(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(b){b.jqplot.MekkoRenderer=function(){this.shapeRenderer=new b.jqplot.ShapeRenderer();this.borderColor=null;this.showBorders=true};b.jqplot.MekkoRenderer.prototype.init=function(c,e){this.fill=false;this.fillRect=true;this.strokeRect=true;this.shadow=false;this._xwidth=0;this._xstart=0;b.extend(true,this.renderer,c);var d={lineJoin:"miter",lineCap:"butt",isarc:false,fillRect:this.fillRect,strokeRect:this.strokeRect};this.renderer.shapeRenderer.init(d);e.axes.x2axis._series.push(this);this._type="mekko"};b.jqplot.MekkoRenderer.prototype.setGridData=function(h){var e=this._xaxis.series_u2p;var c=this._yaxis.series_u2p;var g=this._plotData;this.gridData=[];this._xwidth=e(this._sumy)-e(0);if(this.index>0){this._xstart=h.series[this.index-1]._xstart+h.series[this.index-1]._xwidth}var l=this.canvas.getHeight();var d=0;var k;var j;for(var f=0;f<g.length;f++){if(g[f]!=null){d+=g[f][1];k=l-(d/this._sumy*l);j=g[f][1]/this._sumy*l;this.gridData.push([this._xstart,k,this._xwidth,j])}}};b.jqplot.MekkoRenderer.prototype.makeGridData=function(f,g){var d=this._xaxis.series_u2p;var l=this.canvas.getHeight();var c=0;var j;var h;var k=[];for(var e=0;e<f.length;e++){if(f[e]!=null){c+=f[e][1];j=l-(c/this._sumy*l);h=f[e][1]/this._sumy*l;k.push([this._xstart,j,this._xwidth,h])}}return k};b.jqplot.MekkoRenderer.prototype.draw=function(c,h,d){var e;var g=(d!=undefined)?d:{};var f=(g.showLine!=undefined)?g.showLine:this.showLine;var j=new b.jqplot.ColorGenerator(this.seriesColors);c.save();if(h.length){if(f){for(e=0;e<h.length;e++){g.fillStyle=j.next();if(this.renderer.showBorders){g.strokeStyle=this.renderer.borderColor}else{g.strokeStyle=g.fillStyle}this.renderer.shapeRenderer.draw(c,h[e],g)}}}c.restore()};b.jqplot.MekkoRenderer.prototype.drawShadow=function(c,e,d){};b.jqplot.MekkoLegendRenderer=function(){};b.jqplot.MekkoLegendRenderer.prototype.init=function(c){this.numberRows=null;this.numberColumns=null;this.placement="outside";b.extend(true,this,c)};b.jqplot.MekkoLegendRenderer.prototype.draw=function(){var f=this;if(this.show){var o=this._series;var r="position:absolute;";r+=(this.background)?"background:"+this.background+";":"";r+=(this.border)?"border:"+this.border+";":"";r+=(this.fontSize)?"font-size:"+this.fontSize+";":"";r+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";r+=(this.textColor)?"color:"+this.textColor+";":"";this._elem=b('<table class="jqplot-table-legend" style="'+r+'"></table>');var w=false,n=true,c,l;var p=o[0];var d=new b.jqplot.ColorGenerator(p.seriesColors);if(p.show){var x=p.data;if(this.numberRows){c=this.numberRows;if(!this.numberColumns){l=Math.ceil(x.length/c)}else{l=this.numberColumns}}else{if(this.numberColumns){l=this.numberColumns;c=Math.ceil(x.length/this.numberColumns)}else{c=x.length;l=1}}var v,u,e,h,g,k,m,t;var q=0;for(v=0;v<c;v++){if(n){e=b('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem)}else{e=b('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem)}for(u=0;u<l;u++){if(q<x.length){k=this.labels[q]||x[q][0].toString();t=d.next();if(!n){if(v>0){w=true}else{w=false}}else{if(v==c-1){w=false}else{w=true}}m=(w)?this.rowSpacing:"0";h=b('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+m+';"><div><div class="jqplot-table-legend-swatch" style="border-color:'+t+';"></div></div></td>');g=b('<td class="jqplot-table-legend" style="padding-top:'+m+';"></td>');if(this.escapeHtml){g.text(k)}else{g.html(k)}if(n){g.prependTo(e);h.prependTo(e)}else{h.appendTo(e);g.appendTo(e)}w=true}q++}}e=null;h=null;g=null}}return this._elem};b.jqplot.MekkoLegendRenderer.prototype.pack=function(f){if(this.show){var e={_top:f.top,_left:f.left,_right:f.right,_bottom:this._plotDimensions.height-f.bottom};if(this.placement=="insideGrid"){switch(this.location){case"nw":var d=e._left+this.xoffset;var c=e._top+this.yoffset;this._elem.css("left",d);this._elem.css("top",c);break;case"n":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=e._top+this.yoffset;this._elem.css("left",d);this._elem.css("top",c);break;case"ne":var d=f.right+this.xoffset;var c=e._top+this.yoffset;this._elem.css({right:d,top:c});break;case"e":var d=f.right+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({right:d,top:c});break;case"se":var d=f.right+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({right:d,bottom:c});break;case"s":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=f.bottom+this.yoffset;this._elem.css({left:d,bottom:c});break;case"sw":var d=e._left+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({left:d,bottom:c});break;case"w":var d=e._left+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({left:d,top:c});break;default:var d=e._right-this.xoffset;var c=e._bottom+this.yoffset;this._elem.css({right:d,bottom:c});break}}else{switch(this.location){case"nw":var d=this._plotDimensions.width-e._left+this.xoffset;var c=e._top+this.yoffset;this._elem.css("right",d);this._elem.css("top",c);break;case"n":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=this._plotDimensions.height-e._top+this.yoffset;this._elem.css("left",d);this._elem.css("bottom",c);break;case"ne":var d=this._plotDimensions.width-f.right+this.xoffset;var c=e._top+this.yoffset;this._elem.css({left:d,top:c});break;case"e":var d=this._plotDimensions.width-f.right+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({left:d,top:c});break;case"se":var d=this._plotDimensions.width-f.right+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({left:d,bottom:c});break;case"s":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=this._plotDimensions.height-f.bottom+this.yoffset;this._elem.css({left:d,top:c});break;case"sw":var d=this._plotDimensions.width-e._left+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({right:d,bottom:c});break;case"w":var d=this._plotDimensions.width-e._left+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({right:d,top:c});break;default:var d=e._right-this.xoffset;var c=e._bottom+this.yoffset;this._elem.css({right:d,bottom:c});break}}}};function a(g,f,d){d=d||{};d.axesDefaults=d.axesDefaults||{};d.legend=d.legend||{};d.seriesDefaults=d.seriesDefaults||{};var c=false;if(d.seriesDefaults.renderer==b.jqplot.MekkoRenderer){c=true}else{if(d.series){for(var e=0;e<d.series.length;e++){if(d.series[e].renderer==b.jqplot.MekkoRenderer){c=true}}}}if(c){d.axesDefaults.renderer=b.jqplot.MekkoAxisRenderer;d.legend.renderer=b.jqplot.MekkoLegendRenderer;d.legend.preDraw=true}}b.jqplot.preInitHooks.push(a)})(jQuery);
|