sunrise-votes 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -4
- data/Rakefile +0 -22
- data/app/controllers/manage/ballot_box/votes_controller.rb +4 -0
- data/app/views/manage/ballot_box/votes/show.html.erb +211 -81
- data/lib/generators/sunrise/votes/install_generator.rb +1 -1
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/highcharts.js +170 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/highcharts.src.js +11428 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/modules/exporting.js +22 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/modules/exporting.src.js +711 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/dark-blue.js +263 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/dark-green.js +263 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/gray.js +262 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/grid.js +96 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/skies.js +89 -0
- data/lib/sunrise/votes/version.rb +1 -1
- metadata +33 -79
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/excanvas.min.js +0 -35
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/jquery.jqplot.css +0 -226
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/jquery.jqplot.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.BezierCurveRenderer.js +0 -312
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.BezierCurveRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.barRenderer.js +0 -702
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.barRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.blockRenderer.js +0 -234
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.blockRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.bubbleRenderer.js +0 -748
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.bubbleRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisLabelRenderer.js +0 -199
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisLabelRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisTickRenderer.js +0 -238
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisTickRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasOverlay.js +0 -614
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasOverlay.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasTextRenderer.js +0 -420
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasTextRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.categoryAxisRenderer.js +0 -634
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.categoryAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ciParser.js +0 -115
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ciParser.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.cursor.js +0 -1002
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.cursor.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dateAxisRenderer.js +0 -439
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dateAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.donutRenderer.js +0 -904
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.donutRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dragable.js +0 -218
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dragable.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.enhancedLegendRenderer.js +0 -199
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.enhancedLegendRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.funnelRenderer.js +0 -932
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.funnelRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.highlighter.js +0 -406
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.highlighter.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.json2.js +0 -475
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.json2.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.logAxisRenderer.js +0 -446
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.logAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoAxisRenderer.js +0 -607
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoRenderer.js +0 -432
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.meterGaugeRenderer.js +0 -1142
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.meterGaugeRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ohlcRenderer.js +0 -372
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ohlcRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pieRenderer.js +0 -797
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pieRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.js +0 -337
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.trendline.js +0 -220
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.trendline.min.js +0 -30
@@ -1,30 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* jqPlot
|
3
|
-
* Pure JavaScript plotting plugin using jQuery
|
4
|
-
*
|
5
|
-
* Version: 1.0.0b1_r746
|
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(a){a.jqplot.CanvasAxisTickRenderer=function(b){this.mark="outside";this.showMark=true;this.showGridline=true;this.isMinorTick=false;this.angle=0;this.markSize=4;this.show=true;this.showLabel=true;this.labelPosition="auto";this.label="";this.value=null;this._styles={};this.formatter=a.jqplot.DefaultTickFormatter;this.formatString="";this.prefix="";this.fontFamily='"Trebuchet MS", Arial, Helvetica, sans-serif';this.fontSize="10pt";this.fontWeight="normal";this.fontStretch=1;this.textColor="#666666";this.enableFontSupport=true;this.pt2px=null;this._elem;this._ctx;this._plotWidth;this._plotHeight;this._plotDimensions={height:null,width:null};a.extend(true,this,b);var c={fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily};if(this.pt2px){c.pt2px=this.pt2px}if(this.enableFontSupport){function d(){return !!(document.createElement("canvas").getContext&&typeof document.createElement("canvas").getContext("2d").fillText=="function")}if(d()){this._textRenderer=new a.jqplot.CanvasFontRenderer(c)}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}};a.jqplot.CanvasAxisTickRenderer.prototype.init=function(b){a.extend(true,this,b);this._textRenderer.init({fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily})};a.jqplot.CanvasAxisTickRenderer.prototype.getWidth=function(d){if(this._elem){return this._elem.outerWidth(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.sin(f.angle)*e)+Math.abs(Math.cos(f.angle)*c);return b}};a.jqplot.CanvasAxisTickRenderer.prototype.getHeight=function(d){if(this._elem){return this._elem.outerHeight(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.cos(f.angle)*e)+Math.abs(Math.sin(f.angle)*c);return b}};a.jqplot.CanvasAxisTickRenderer.prototype.getAngleRad=function(){var b=this.angle*Math.PI/180;return b};a.jqplot.CanvasAxisTickRenderer.prototype.setTick=function(b,d,c){this.value=b;if(c){this.isMinorTick=true}return this};a.jqplot.CanvasAxisTickRenderer.prototype.draw=function(c){if(!this.label){this.label=this.formatter(this.formatString,this.value)}if(this.prefix&&!this.formatString){this.label=this.prefix+this.label}var e=document.createElement("canvas");this._textRenderer.setText(this.label,c);var b=this.getWidth(c);var d=this.getHeight(c);e.width=b;e.height=d;e.style.width=b;e.style.height=d;e.style.textAlign="left";e.style.position="absolute";this._domelem=e;this._elem=a(e);this._elem.css(this._styles);this._elem.addClass("jqplot-"+this.axis+"-tick");e=null;return this._elem};a.jqplot.CanvasAxisTickRenderer.prototype.pack=function(){if(a.jqplot.use_excanvas){window.G_vmlCanvasManager.init_(document);this._domelem=window.G_vmlCanvasManager.initElement(this._domelem)}this._textRenderer.draw(this._elem.get(0).getContext("2d"),this.label)}})(jQuery);
|
data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasOverlay.js
DELETED
@@ -1,614 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* jqPlot
|
3
|
-
* Pure JavaScript plotting plugin using jQuery
|
4
|
-
*
|
5
|
-
* Version: 1.0.0b1_r746
|
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
|
-
// class: $.jqplot.CanvasOverlay
|
32
|
-
$.jqplot.CanvasOverlay = function(opts){
|
33
|
-
var options = opts || {};
|
34
|
-
this.options = {
|
35
|
-
show: $.jqplot.config.enablePlugins,
|
36
|
-
deferDraw: false
|
37
|
-
};
|
38
|
-
// prop: objects
|
39
|
-
this.objects = [];
|
40
|
-
this.objectNames = [];
|
41
|
-
this.canvas = null;
|
42
|
-
this.markerRenderer = new $.jqplot.MarkerRenderer({style:'line'});
|
43
|
-
this.markerRenderer.init();
|
44
|
-
if (options.objects) {
|
45
|
-
var objs = options.objects,
|
46
|
-
obj;
|
47
|
-
for (var i=0; i<objs.length; i++) {
|
48
|
-
obj = objs[i];
|
49
|
-
for (var n in obj) {
|
50
|
-
switch (n) {
|
51
|
-
case 'line':
|
52
|
-
this.addLine(obj[n]);
|
53
|
-
break;
|
54
|
-
case 'horizontalLine':
|
55
|
-
this.addHorizontalLine(obj[n]);
|
56
|
-
break;
|
57
|
-
case 'dashedHorizontalLine':
|
58
|
-
this.addDashedHorizontalLine(obj[n]);
|
59
|
-
break;
|
60
|
-
case 'verticalLine':
|
61
|
-
this.addVerticalLine(obj[n]);
|
62
|
-
break;
|
63
|
-
case 'dashedVerticalLine':
|
64
|
-
this.addDashedVerticalLine(obj[n]);
|
65
|
-
break;
|
66
|
-
default:
|
67
|
-
break;
|
68
|
-
}
|
69
|
-
}
|
70
|
-
}
|
71
|
-
}
|
72
|
-
$.extend(true, this.options, options);
|
73
|
-
};
|
74
|
-
|
75
|
-
// called with scope of a plot object
|
76
|
-
$.jqplot.CanvasOverlay.postPlotInit = function (target, data, opts) {
|
77
|
-
var options = opts || {};
|
78
|
-
// add a canvasOverlay attribute to the plot
|
79
|
-
this.plugins.canvasOverlay = new $.jqplot.CanvasOverlay(options.canvasOverlay);
|
80
|
-
};
|
81
|
-
|
82
|
-
function Line(options) {
|
83
|
-
this.type = 'line';
|
84
|
-
this.options = {
|
85
|
-
name: null,
|
86
|
-
show: true,
|
87
|
-
lineWidth: 2,
|
88
|
-
lineCap: 'round',
|
89
|
-
color: '#666666',
|
90
|
-
// prop: shadow
|
91
|
-
// wether or not to draw a shadow on the line
|
92
|
-
shadow: true,
|
93
|
-
// prop: shadowAngle
|
94
|
-
// Shadow angle in degrees
|
95
|
-
shadowAngle: 45,
|
96
|
-
// prop: shadowOffset
|
97
|
-
// Shadow offset from line in pixels
|
98
|
-
shadowOffset: 1,
|
99
|
-
// prop: shadowDepth
|
100
|
-
// Number of times shadow is stroked, each stroke offset shadowOffset from the last.
|
101
|
-
shadowDepth: 3,
|
102
|
-
// prop: shadowAlpha
|
103
|
-
// Alpha channel transparency of shadow. 0 = transparent.
|
104
|
-
shadowAlpha: '0.07',
|
105
|
-
xaxis: 'xaxis',
|
106
|
-
yaxis: 'yaxis',
|
107
|
-
start: [],
|
108
|
-
stop: []
|
109
|
-
};
|
110
|
-
$.extend(true, this.options, options);
|
111
|
-
}
|
112
|
-
|
113
|
-
function HorizontalLine(options) {
|
114
|
-
this.type = 'horizontalLine';
|
115
|
-
this.options = {
|
116
|
-
name: null,
|
117
|
-
show: true,
|
118
|
-
lineWidth: 2,
|
119
|
-
lineCap: 'round',
|
120
|
-
color: '#666666',
|
121
|
-
// prop: shadow
|
122
|
-
// wether or not to draw a shadow on the line
|
123
|
-
shadow: true,
|
124
|
-
// prop: shadowAngle
|
125
|
-
// Shadow angle in degrees
|
126
|
-
shadowAngle: 45,
|
127
|
-
// prop: shadowOffset
|
128
|
-
// Shadow offset from line in pixels
|
129
|
-
shadowOffset: 1,
|
130
|
-
// prop: shadowDepth
|
131
|
-
// Number of times shadow is stroked, each stroke offset shadowOffset from the last.
|
132
|
-
shadowDepth: 3,
|
133
|
-
// prop: shadowAlpha
|
134
|
-
// Alpha channel transparency of shadow. 0 = transparent.
|
135
|
-
shadowAlpha: '0.07',
|
136
|
-
// prop: xaxis
|
137
|
-
// For drawing, canvas has to know which x-y axes to scale to.
|
138
|
-
// Specify the desired x axis here.
|
139
|
-
xaxis: 'xaxis',
|
140
|
-
// prop: yaxis
|
141
|
-
// For drawing, canvas has to know which x-y axes to scale to.
|
142
|
-
// Specify the desired y axis here.
|
143
|
-
yaxis: 'yaxis',
|
144
|
-
y: null,
|
145
|
-
xmin: null,
|
146
|
-
xmax: null,
|
147
|
-
xOffset: '6px', // number or string. Number interpreted as units, string as pixels.
|
148
|
-
xminOffset: null,
|
149
|
-
xmaxOffset: null
|
150
|
-
};
|
151
|
-
$.extend(true, this.options, options);
|
152
|
-
}
|
153
|
-
|
154
|
-
function DashedHorizontalLine(options) {
|
155
|
-
this.type = 'dashedHorizontalLine';
|
156
|
-
this.options = {
|
157
|
-
name: null,
|
158
|
-
show: true,
|
159
|
-
lineWidth: 2,
|
160
|
-
lineCap: 'butt',
|
161
|
-
color: '#666666',
|
162
|
-
// prop: shadow
|
163
|
-
// wether or not to draw a shadow on the line
|
164
|
-
shadow: true,
|
165
|
-
// prop: shadowAngle
|
166
|
-
// Shadow angle in degrees
|
167
|
-
shadowAngle: 45,
|
168
|
-
// prop: shadowOffset
|
169
|
-
// Shadow offset from line in pixels
|
170
|
-
shadowOffset: 1,
|
171
|
-
// prop: shadowDepth
|
172
|
-
// Number of times shadow is stroked, each stroke offset shadowOffset from the last.
|
173
|
-
shadowDepth: 3,
|
174
|
-
// prop: shadowAlpha
|
175
|
-
// Alpha channel transparency of shadow. 0 = transparent.
|
176
|
-
shadowAlpha: '0.07',
|
177
|
-
// prop: xaxis
|
178
|
-
// For drawing, canvas has to know which x-y axes to scale to.
|
179
|
-
// Specify the desired x axis here.
|
180
|
-
xaxis: 'xaxis',
|
181
|
-
// prop: yaxis
|
182
|
-
// For drawing, canvas has to know which x-y axes to scale to.
|
183
|
-
// Specify the desired y axis here.
|
184
|
-
yaxis: 'yaxis',
|
185
|
-
y: null,
|
186
|
-
xmin: null,
|
187
|
-
xmax: null,
|
188
|
-
xOffset: '6px', // number or string. Number interpreted as units, string as pixels.
|
189
|
-
xminOffset: null,
|
190
|
-
xmaxOffset: null,
|
191
|
-
// prop: dashPattern
|
192
|
-
// Array of line, space settings in pixels.
|
193
|
-
// Default is 8 pixel of line, 8 pixel of space.
|
194
|
-
// Note, limit to a 2 element array b/c of bug with higher order arrays.
|
195
|
-
dashPattern: [8,8]
|
196
|
-
};
|
197
|
-
$.extend(true, this.options, options);
|
198
|
-
}
|
199
|
-
|
200
|
-
function VerticalLine(options) {
|
201
|
-
this.type = 'verticalLine';
|
202
|
-
this.options = {
|
203
|
-
name: null,
|
204
|
-
show: true,
|
205
|
-
lineWidth: 2,
|
206
|
-
lineCap: 'round',
|
207
|
-
color: '#666666',
|
208
|
-
// prop: shadow
|
209
|
-
// wether or not to draw a shadow on the line
|
210
|
-
shadow: true,
|
211
|
-
// prop: shadowAngle
|
212
|
-
// Shadow angle in degrees
|
213
|
-
shadowAngle: 45,
|
214
|
-
// prop: shadowOffset
|
215
|
-
// Shadow offset from line in pixels
|
216
|
-
shadowOffset: 1,
|
217
|
-
// prop: shadowDepth
|
218
|
-
// Number of times shadow is stroked, each stroke offset shadowOffset from the last.
|
219
|
-
shadowDepth: 3,
|
220
|
-
// prop: shadowAlpha
|
221
|
-
// Alpha channel transparency of shadow. 0 = transparent.
|
222
|
-
shadowAlpha: '0.07',
|
223
|
-
// prop: xaxis
|
224
|
-
// For drawing, canvas has to know which x-y axes to scale to.
|
225
|
-
// Specify the desired x axis here.
|
226
|
-
xaxis: 'xaxis',
|
227
|
-
// prop: yaxis
|
228
|
-
// For drawing, canvas has to know which x-y axes to scale to.
|
229
|
-
// Specify the desired y axis here.
|
230
|
-
yaxis: 'yaxis',
|
231
|
-
x: null,
|
232
|
-
ymin: null,
|
233
|
-
ymax: null,
|
234
|
-
yOffset: '6px', // number or string. Number interpreted as units, string as pixels.
|
235
|
-
yminOffset: null,
|
236
|
-
ymaxOffset: null
|
237
|
-
};
|
238
|
-
$.extend(true, this.options, options);
|
239
|
-
}
|
240
|
-
|
241
|
-
function DashedVerticalLine(options) {
|
242
|
-
this.type = 'dashedVerticalLine';
|
243
|
-
this.options = {
|
244
|
-
name: null,
|
245
|
-
show: true,
|
246
|
-
lineWidth: 2,
|
247
|
-
lineCap: 'butt',
|
248
|
-
color: '#666666',
|
249
|
-
// prop: shadow
|
250
|
-
// wether or not to draw a shadow on the line
|
251
|
-
shadow: true,
|
252
|
-
// prop: shadowAngle
|
253
|
-
// Shadow angle in degrees
|
254
|
-
shadowAngle: 45,
|
255
|
-
// prop: shadowOffset
|
256
|
-
// Shadow offset from line in pixels
|
257
|
-
shadowOffset: 1,
|
258
|
-
// prop: shadowDepth
|
259
|
-
// Number of times shadow is stroked, each stroke offset shadowOffset from the last.
|
260
|
-
shadowDepth: 3,
|
261
|
-
// prop: shadowAlpha
|
262
|
-
// Alpha channel transparency of shadow. 0 = transparent.
|
263
|
-
shadowAlpha: '0.07',
|
264
|
-
// prop: xaxis
|
265
|
-
// For drawing, canvas has to know which x-y axes to scale to.
|
266
|
-
// Specify the desired x axis here.
|
267
|
-
xaxis: 'xaxis',
|
268
|
-
// prop: yaxis
|
269
|
-
// For drawing, canvas has to know which x-y axes to scale to.
|
270
|
-
// Specify the desired y axis here.
|
271
|
-
yaxis: 'yaxis',
|
272
|
-
x: null,
|
273
|
-
ymin: null,
|
274
|
-
ymax: null,
|
275
|
-
yOffset: '6px', // number or string. Number interpreted as units, string as pixels.
|
276
|
-
yminOffset: null,
|
277
|
-
ymaxOffset: null,
|
278
|
-
// prop: dashPattern
|
279
|
-
// Array of line, space settings in pixels.
|
280
|
-
// Default is 8 pixel of line, 8 pixel of space.
|
281
|
-
// Note, limit to a 2 element array b/c of bug with higher order arrays.
|
282
|
-
dashPattern: [8,8]
|
283
|
-
};
|
284
|
-
$.extend(true, this.options, options);
|
285
|
-
}
|
286
|
-
|
287
|
-
$.jqplot.CanvasOverlay.prototype.addLine = function(opts) {
|
288
|
-
var line = new Line(opts);
|
289
|
-
this.objects.push(line);
|
290
|
-
this.objectNames.push(line.options.name);
|
291
|
-
};
|
292
|
-
|
293
|
-
$.jqplot.CanvasOverlay.prototype.addHorizontalLine = function(opts) {
|
294
|
-
var line = new HorizontalLine(opts);
|
295
|
-
this.objects.push(line);
|
296
|
-
this.objectNames.push(line.options.name);
|
297
|
-
};
|
298
|
-
|
299
|
-
$.jqplot.CanvasOverlay.prototype.addDashedHorizontalLine = function(opts) {
|
300
|
-
var line = new DashedHorizontalLine(opts);
|
301
|
-
this.objects.push(line);
|
302
|
-
this.objectNames.push(line.options.name);
|
303
|
-
};
|
304
|
-
|
305
|
-
$.jqplot.CanvasOverlay.prototype.addVerticalLine = function(opts) {
|
306
|
-
var line = new VerticalLine(opts);
|
307
|
-
this.objects.push(line);
|
308
|
-
this.objectNames.push(line.options.name);
|
309
|
-
};
|
310
|
-
|
311
|
-
$.jqplot.CanvasOverlay.prototype.addDashedVerticalLine = function(opts) {
|
312
|
-
var line = new DashedVerticalLine(opts);
|
313
|
-
this.objects.push(line);
|
314
|
-
this.objectNames.push(line.options.name);
|
315
|
-
};
|
316
|
-
|
317
|
-
$.jqplot.CanvasOverlay.prototype.removeObject = function(idx) {
|
318
|
-
// check if integer, remove by index
|
319
|
-
if ($.type(idx) == 'number') {
|
320
|
-
this.objects.splice(idx, 1);
|
321
|
-
this.objectNames.splice(idx, 1);
|
322
|
-
}
|
323
|
-
// if string, remove by name
|
324
|
-
else {
|
325
|
-
var id = $.inArray(idx, this.objectNames);
|
326
|
-
if (id != -1) {
|
327
|
-
this.objects.splice(id, 1);
|
328
|
-
this.objectNames.splice(id, 1);
|
329
|
-
}
|
330
|
-
}
|
331
|
-
};
|
332
|
-
|
333
|
-
$.jqplot.CanvasOverlay.prototype.getObject = function(idx) {
|
334
|
-
// check if integer, remove by index
|
335
|
-
if ($.type(idx) == 'number') {
|
336
|
-
return this.objects[idx];
|
337
|
-
}
|
338
|
-
// if string, remove by name
|
339
|
-
else {
|
340
|
-
var id = $.inArray(idx, this.objectNames);
|
341
|
-
if (id != -1) {
|
342
|
-
return this.objects[id];
|
343
|
-
}
|
344
|
-
}
|
345
|
-
};
|
346
|
-
|
347
|
-
// Set get as alias for getObject.
|
348
|
-
$.jqplot.CanvasOverlay.prototype.get = $.jqplot.CanvasOverlay.prototype.getObject;
|
349
|
-
|
350
|
-
$.jqplot.CanvasOverlay.prototype.clear = function(plot) {
|
351
|
-
this.canvas._ctx.clearRect(0,0,this.canvas.getWidth(), this.canvas.getHeight());
|
352
|
-
};
|
353
|
-
|
354
|
-
$.jqplot.CanvasOverlay.prototype.draw = function(plot) {
|
355
|
-
var obj,
|
356
|
-
objs = this.objects,
|
357
|
-
mr = this.markerRenderer,
|
358
|
-
start,
|
359
|
-
stop;
|
360
|
-
if (this.options.show) {
|
361
|
-
this.canvas._ctx.clearRect(0,0,this.canvas.getWidth(), this.canvas.getHeight());
|
362
|
-
for (var k=0; k<objs.length; k++) {
|
363
|
-
obj = objs[k];
|
364
|
-
var opts = $.extend(true, {}, obj.options);
|
365
|
-
if (obj.options.show) {
|
366
|
-
// style and shadow properties should be set before
|
367
|
-
// every draw of marker renderer.
|
368
|
-
mr.shadow = obj.options.shadow;
|
369
|
-
switch (obj.type) {
|
370
|
-
case 'line':
|
371
|
-
// style and shadow properties should be set before
|
372
|
-
// every draw of marker renderer.
|
373
|
-
mr.style = 'line';
|
374
|
-
opts.closePath = false;
|
375
|
-
start = [plot.axes[obj.options.xaxis].series_u2p(obj.options.start[0]), plot.axes[obj.options.yaxis].series_u2p(obj.options.start[1])];
|
376
|
-
stop = [plot.axes[obj.options.xaxis].series_u2p(obj.options.stop[0]), plot.axes[obj.options.yaxis].series_u2p(obj.options.stop[1])];
|
377
|
-
mr.draw(start, stop, this.canvas._ctx, opts);
|
378
|
-
break;
|
379
|
-
case 'horizontalLine':
|
380
|
-
|
381
|
-
// style and shadow properties should be set before
|
382
|
-
// every draw of marker renderer.
|
383
|
-
if (obj.options.y != null) {
|
384
|
-
mr.style = 'line';
|
385
|
-
opts.closePath = false;
|
386
|
-
var xaxis = plot.axes[obj.options.xaxis],
|
387
|
-
xstart,
|
388
|
-
xstop,
|
389
|
-
y = plot.axes[obj.options.yaxis].series_u2p(obj.options.y),
|
390
|
-
xminoff = obj.options.xminOffset || obj.options.xOffset,
|
391
|
-
xmaxoff = obj.options.xmaxOffset || obj.options.xOffset;
|
392
|
-
if (obj.options.xmin != null) {
|
393
|
-
xstart = xaxis.series_u2p(obj.options.xmin);
|
394
|
-
}
|
395
|
-
else if (xminoff != null) {
|
396
|
-
if ($.type(xminoff) == "number") {
|
397
|
-
xstart = xaxis.series_u2p(xaxis.min + xminoff);
|
398
|
-
}
|
399
|
-
else if ($.type(xminoff) == "string") {
|
400
|
-
xstart = xaxis.series_u2p(xaxis.min) + parseFloat(xminoff);
|
401
|
-
}
|
402
|
-
}
|
403
|
-
if (obj.options.xmax != null) {
|
404
|
-
xstop = xaxis.series_u2p(obj.options.xmax);
|
405
|
-
}
|
406
|
-
else if (xmaxoff != null) {
|
407
|
-
if ($.type(xmaxoff) == "number") {
|
408
|
-
xstop = xaxis.series_u2p(xaxis.max - xmaxoff);
|
409
|
-
}
|
410
|
-
else if ($.type(xmaxoff) == "string") {
|
411
|
-
xstop = xaxis.series_u2p(xaxis.max) - parseFloat(xmaxoff);
|
412
|
-
}
|
413
|
-
}
|
414
|
-
if (xstop != null && xstart != null) {
|
415
|
-
mr.draw([xstart, y], [xstop, y], this.canvas._ctx, opts);
|
416
|
-
}
|
417
|
-
}
|
418
|
-
break;
|
419
|
-
|
420
|
-
case 'dashedHorizontalLine':
|
421
|
-
|
422
|
-
var dashPat = obj.options.dashPattern;
|
423
|
-
var dashPatLen = 0;
|
424
|
-
for (var i=0; i<dashPat.length; i++) {
|
425
|
-
dashPatLen += dashPat[i];
|
426
|
-
}
|
427
|
-
|
428
|
-
// style and shadow properties should be set before
|
429
|
-
// every draw of marker renderer.
|
430
|
-
if (obj.options.y != null) {
|
431
|
-
mr.style = 'line';
|
432
|
-
opts.closePath = false;
|
433
|
-
var xaxis = plot.axes[obj.options.xaxis],
|
434
|
-
xstart,
|
435
|
-
xstop,
|
436
|
-
y = plot.axes[obj.options.yaxis].series_u2p(obj.options.y),
|
437
|
-
xminoff = obj.options.xminOffset || obj.options.xOffset,
|
438
|
-
xmaxoff = obj.options.xmaxOffset || obj.options.xOffset;
|
439
|
-
if (obj.options.xmin != null) {
|
440
|
-
xstart = xaxis.series_u2p(obj.options.xmin);
|
441
|
-
}
|
442
|
-
else if (xminoff != null) {
|
443
|
-
if ($.type(xminoff) == "number") {
|
444
|
-
xstart = xaxis.series_u2p(xaxis.min + xminoff);
|
445
|
-
}
|
446
|
-
else if ($.type(xminoff) == "string") {
|
447
|
-
xstart = xaxis.series_u2p(xaxis.min) + parseFloat(xminoff);
|
448
|
-
}
|
449
|
-
}
|
450
|
-
if (obj.options.xmax != null) {
|
451
|
-
xstop = xaxis.series_u2p(obj.options.xmax);
|
452
|
-
}
|
453
|
-
else if (xmaxoff != null) {
|
454
|
-
if ($.type(xmaxoff) == "number") {
|
455
|
-
xstop = xaxis.series_u2p(xaxis.max - xmaxoff);
|
456
|
-
}
|
457
|
-
else if ($.type(xmaxoff) == "string") {
|
458
|
-
xstop = xaxis.series_u2p(xaxis.max) - parseFloat(xmaxoff);
|
459
|
-
}
|
460
|
-
}
|
461
|
-
if (xstop != null && xstart != null) {
|
462
|
-
var numDash = Math.ceil((xstop - xstart)/dashPatLen);
|
463
|
-
var b=xstart, e;
|
464
|
-
for (var i=0; i<numDash; i++) {
|
465
|
-
for (var j=0; j<dashPat.length; j+=2) {
|
466
|
-
e = b+dashPat[j];
|
467
|
-
mr.draw([b, y], [e, y], this.canvas._ctx, opts);
|
468
|
-
b += dashPat[j];
|
469
|
-
if (j < dashPat.length-1) {
|
470
|
-
b += dashPat[j+1];
|
471
|
-
}
|
472
|
-
}
|
473
|
-
}
|
474
|
-
}
|
475
|
-
}
|
476
|
-
break;
|
477
|
-
|
478
|
-
case 'verticalLine':
|
479
|
-
|
480
|
-
// style and shadow properties should be set before
|
481
|
-
// every draw of marker renderer.
|
482
|
-
if (obj.options.x != null) {
|
483
|
-
mr.style = 'line';
|
484
|
-
opts.closePath = false;
|
485
|
-
var yaxis = plot.axes[obj.options.yaxis],
|
486
|
-
ystart,
|
487
|
-
ystop,
|
488
|
-
x = plot.axes[obj.options.xaxis].series_u2p(obj.options.x),
|
489
|
-
yminoff = obj.options.yminOffset || obj.options.yOffset,
|
490
|
-
ymaxoff = obj.options.ymaxOffset || obj.options.yOffset;
|
491
|
-
if (obj.options.ymin != null) {
|
492
|
-
ystart = yaxis.series_u2p(obj.options.ymin);
|
493
|
-
}
|
494
|
-
else if (yminoff != null) {
|
495
|
-
if ($.type(yminoff) == "number") {
|
496
|
-
ystart = yaxis.series_u2p(yaxis.min - yminoff);
|
497
|
-
}
|
498
|
-
else if ($.type(yminoff) == "string") {
|
499
|
-
ystart = yaxis.series_u2p(yaxis.min) - parseFloat(yminoff);
|
500
|
-
}
|
501
|
-
}
|
502
|
-
if (obj.options.ymax != null) {
|
503
|
-
ystop = yaxis.series_u2p(obj.options.ymax);
|
504
|
-
}
|
505
|
-
else if (ymaxoff != null) {
|
506
|
-
if ($.type(ymaxoff) == "number") {
|
507
|
-
ystop = yaxis.series_u2p(yaxis.max + ymaxoff);
|
508
|
-
}
|
509
|
-
else if ($.type(ymaxoff) == "string") {
|
510
|
-
ystop = yaxis.series_u2p(yaxis.max) + parseFloat(ymaxoff);
|
511
|
-
}
|
512
|
-
}
|
513
|
-
if (ystop != null && ystart != null) {
|
514
|
-
mr.draw([x, ystart], [x, ystop], this.canvas._ctx, opts);
|
515
|
-
}
|
516
|
-
}
|
517
|
-
break;
|
518
|
-
|
519
|
-
case 'dashedVerticalLine':
|
520
|
-
|
521
|
-
var dashPat = obj.options.dashPattern;
|
522
|
-
var dashPatLen = 0;
|
523
|
-
for (var i=0; i<dashPat.length; i++) {
|
524
|
-
dashPatLen += dashPat[i];
|
525
|
-
}
|
526
|
-
|
527
|
-
// style and shadow properties should be set before
|
528
|
-
// every draw of marker renderer.
|
529
|
-
if (obj.options.x != null) {
|
530
|
-
mr.style = 'line';
|
531
|
-
opts.closePath = false;
|
532
|
-
var yaxis = plot.axes[obj.options.yaxis],
|
533
|
-
ystart,
|
534
|
-
ystop,
|
535
|
-
x = plot.axes[obj.options.xaxis].series_u2p(obj.options.x),
|
536
|
-
yminoff = obj.options.yminOffset || obj.options.yOffset,
|
537
|
-
ymaxoff = obj.options.ymaxOffset || obj.options.yOffset;
|
538
|
-
if (obj.options.ymin != null) {
|
539
|
-
ystart = yaxis.series_u2p(obj.options.ymin);
|
540
|
-
}
|
541
|
-
else if (yminoff != null) {
|
542
|
-
if ($.type(yminoff) == "number") {
|
543
|
-
ystart = yaxis.series_u2p(yaxis.min - yminoff);
|
544
|
-
}
|
545
|
-
else if ($.type(yminoff) == "string") {
|
546
|
-
ystart = yaxis.series_u2p(yaxis.min) - parseFloat(yminoff);
|
547
|
-
}
|
548
|
-
}
|
549
|
-
if (obj.options.ymax != null) {
|
550
|
-
ystop = yaxis.series_u2p(obj.options.ymax);
|
551
|
-
}
|
552
|
-
else if (ymaxoff != null) {
|
553
|
-
if ($.type(ymaxoff) == "number") {
|
554
|
-
ystop = yaxis.series_u2p(yaxis.max + ymaxoff);
|
555
|
-
}
|
556
|
-
else if ($.type(ymaxoff) == "string") {
|
557
|
-
ystop = yaxis.series_u2p(yaxis.max) + parseFloat(ymaxoff);
|
558
|
-
}
|
559
|
-
}
|
560
|
-
|
561
|
-
|
562
|
-
if (ystop != null && ystart != null) {
|
563
|
-
var numDash = Math.ceil((ystart - ystop)/dashPatLen);
|
564
|
-
var firstDashAdjust = ((numDash * dashPatLen) - (ystart - ystop))/2.0;
|
565
|
-
var b=ystart, e, bs, es;
|
566
|
-
for (var i=0; i<numDash; i++) {
|
567
|
-
for (var j=0; j<dashPat.length; j+=2) {
|
568
|
-
e = b - dashPat[j];
|
569
|
-
if (e < ystop) {
|
570
|
-
e = ystop;
|
571
|
-
}
|
572
|
-
if (b < ystop) {
|
573
|
-
b = ystop;
|
574
|
-
}
|
575
|
-
// es = e;
|
576
|
-
// if (i == 0) {
|
577
|
-
// es += firstDashAdjust;
|
578
|
-
// }
|
579
|
-
mr.draw([x, b], [x, e], this.canvas._ctx, opts);
|
580
|
-
b -= dashPat[j];
|
581
|
-
if (j < dashPat.length-1) {
|
582
|
-
b -= dashPat[j+1];
|
583
|
-
}
|
584
|
-
}
|
585
|
-
}
|
586
|
-
}
|
587
|
-
}
|
588
|
-
break;
|
589
|
-
|
590
|
-
default:
|
591
|
-
break;
|
592
|
-
}
|
593
|
-
}
|
594
|
-
}
|
595
|
-
}
|
596
|
-
};
|
597
|
-
|
598
|
-
// called within context of plot
|
599
|
-
// create a canvas which we can draw on.
|
600
|
-
// insert it before the eventCanvas, so eventCanvas will still capture events.
|
601
|
-
$.jqplot.CanvasOverlay.postPlotDraw = function() {
|
602
|
-
this.plugins.canvasOverlay.canvas = new $.jqplot.GenericCanvas();
|
603
|
-
|
604
|
-
this.eventCanvas._elem.before(this.plugins.canvasOverlay.canvas.createElement(this._gridPadding, 'jqplot-overlayCanvas-canvas', this._plotDimensions));
|
605
|
-
this.plugins.canvasOverlay.canvas.setContext();
|
606
|
-
if (!this.plugins.canvasOverlay.deferDraw) {
|
607
|
-
this.plugins.canvasOverlay.draw(this);
|
608
|
-
}
|
609
|
-
};
|
610
|
-
|
611
|
-
$.jqplot.postInitHooks.push($.jqplot.CanvasOverlay.postPlotInit);
|
612
|
-
$.jqplot.postDrawHooks.push($.jqplot.CanvasOverlay.postPlotDraw);
|
613
|
-
|
614
|
-
})(jQuery);
|